Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XAML STYLER as a Git-Hook #1422

Open
4 tasks
Jay-o-Way opened this issue Dec 24, 2023 · 11 comments
Open
4 tasks

XAML STYLER as a Git-Hook #1422

Jay-o-Way opened this issue Dec 24, 2023 · 11 comments

Comments

@Jay-o-Way
Copy link
Contributor

Jay-o-Way commented Dec 24, 2023

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

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

@Jay-o-Way
Copy link
Contributor Author

I can do this 😇

@Jay-o-Way
Copy link
Contributor Author

Jay-o-Way commented Jan 16, 2024

@chingucoding or @karkarl any thoughts?

@karkarl
Copy link
Collaborator

karkarl commented Jan 17, 2024

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.

@Jay-o-Way
Copy link
Contributor Author

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.)

@marcelwgn
Copy link
Collaborator

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?

@Jay-o-Way
Copy link
Contributor Author

Jay-o-Way commented Jan 23, 2024

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 Xavalon/XamlStyler#454

@Jay-o-Way Jay-o-Way changed the title XAML STYLER XAML STYLER as a Git-Hook Jan 23, 2024
@Jay-o-Way
Copy link
Contributor Author

Jay-o-Way commented Feb 8, 2024

@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
Copy link
Contributor Author

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>

@karkarl
Copy link
Collaborator

karkarl commented Feb 22, 2024

Linking this to this task in backlog #1279

@Jay-o-Way
Copy link
Contributor Author

Alternatively, we could add XAML Styler to .vsconfig?

@Jay-o-Way
Copy link
Contributor Author

Example of pr: files-community/Files#15115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants