WinUI-Gallery icon indicating copy to clipboard operation
WinUI-Gallery copied to clipboard

XAML STYLER as a Git-Hook

Open Jay-o-Way opened this issue 2 years ago • 12 comments

Issue type

enhancement

Which version of the app?

WinUI 3 Gallery

Description

https://github.com/Xavalon/XamlStyler/wiki/Git-Hook

Additional context

  • Do we need a Settings.XamlStyler file? If yes, which settings would be different?
### Tasks
- [ ] ❔ Settings.XamlStyler file
- [ ] prepare <elements> with `space=preserve`
- [ ] let XamlStyler do its magic* 🪄
- [ ] check content of <elements> ... think manual line endings and LineBreaks 🕵🏻‍♂️

[!NOTE] Need to set xml:space="preserve" in elements first, in order to prevent the following: In a paragraph of text, a <Hyperlink> or a <Bold> will be stripped of a preceding space. By contrast, a period following a </Hyperlink> or a </Bold> wil be placed on a new line. This will insert a [space] in the UI. image

  • https://github.com/Xavalon/XamlStyler/wiki/Getting-Started#whitespace
  • Q&A https://github.com/Xavalon/XamlStyler/issues/454

Jay-o-Way avatar Dec 24 '23 21:12 Jay-o-Way

I can do this 😇

Jay-o-Way avatar Dec 28 '23 17:12 Jay-o-Way

@chingucoding or @karkarl any thoughts?

Jay-o-Way avatar Jan 16 '24 10:01 Jay-o-Way

Thanks so much for tackling this @Jay-o-Way! As you know already cleaning up the XAML is in the backlog as part of the efforts to clean up the codebase.

I like the idea of a Settings.XamlStyler file should we have future customizations, and so it's easier to reference implemented rules.

karkarl avatar Jan 17 '24 18:01 karkarl

Thanks for the positive comment @karkarl :) Imma need a bit more specific answers to adress this, mainly the choice between a one-time (manual) execution or the workflow solution. (easy versus not-so-easy, resp.)

Jay-o-Way avatar Jan 23 '24 12:01 Jay-o-Way

Sorry for hoping on this topic so late, I think if we don't do it as part of the CI or a git hook (if that is an option), slowly this would diverge again. I think having a config for this is also necessary to avoid mixed formatting based on who is doing it.

The issue you linked though is a bit worrysome, is there a way to work around that formatting of text?

marcelwgn avatar Jan 23 '24 15:01 marcelwgn

I think having a config for this is also necessary to avoid mixed formatting based on who is doing it.

If it's done via a central hook, this is a non-issue, because the changes are not made by people. :) Default settings should be fine (to start with)

is there a way to work around that formatting of text?

You mean the unintended changes with spaces? I believe setting the space=preserve is the solution. I adressed this in issue https://github.com/Xavalon/XamlStyler/issues/454

Jay-o-Way avatar Jan 23 '24 15:01 Jay-o-Way

@niels9001 Currently, there are a lot of RichTextBlock + Paragraph constructions. Mostly used for formatting text and including Hyperlinks. Adjusting them to add space=preserve, is a huge p.i.t.a. and the resulting xaml is not pretty. Because text needs to be on one line. I think it would be a lot more efficient - and pretty - to use a MarkdownTextblock. Even though rewriting the code is a lot of work too... ⚖️ wdyt?

(totally random example)

<RichTextBlock xml:space="preserve">
 <Paragraph>To use the keyboard with a control, the control must have focus. The most common way to receive focus is via <Bold>Tab navigation</Bold>, which cycles through controls that are <Bold>tab stops</Bold>. The order of these tab stops is called the <Bold>tab order</Bold>.</Paragraph>
 <Paragraph>All interactive controls, like buttons, should be tab stops (unless they are in a group that's accessible in some other way), but non-interactive controls, like labels, should not. Try to put initial focus on the most useful or logical element.</Paragraph>
 <Paragraph>See <Hyperlink NavigateUri="https://learn.microsoft.com/windows/apps/design/input/keyboard-interactions">Keyboard interactions</Hyperlink> and <Hyperlink NavigateUri="https://learn.microsoft.com/windows/apps/design/accessibility/keyboard-accessibility">Keyboard accessibility</Hyperlink>.</Paragraph>
</RichTextBlock>

Jay-o-Way avatar Feb 08 '24 21:02 Jay-o-Way

Also, cases like the following might be too much XAML for simple text

<RichTextBlock
 x:Name="ErrorTextBlock"
 Grid.Row="1"
 Margin="0,0,0,12"
 Foreground="{ThemeResource SystemFillColorCriticalBrush}"
 IsTextSelectionEnabled="True"
 Visibility="Collapsed">
 <Paragraph xml:space="preserve">
 This sample requires a later version of Windows to be fully functional.
 </Paragraph>
</RichTextBlock>

Jay-o-Way avatar Feb 08 '24 22:02 Jay-o-Way

Linking this to this task in backlog #1279

karkarl avatar Feb 22 '24 19:02 karkarl

Alternatively, we could add XAML Styler to .vsconfig?

Jay-o-Way avatar Feb 29 '24 16:02 Jay-o-Way

Example of pr: https://github.com/files-community/Files/pull/15115

Jay-o-Way avatar Apr 05 '24 00:04 Jay-o-Way