Skip to content

Commit 47849c3

Browse files
dvoituronvnbaaij
andauthored
[dev-v5] Add markdown shortcuts [!NOTE], [!TIP] and [!WARNING] (#3770)
* Add [!NOTE] [!TIP] [!WARNING] * Update md files --------- Co-authored-by: Vincent Baaij <[email protected]>
1 parent a080b58 commit 47849c3

File tree

11 files changed

+59
-24
lines changed

11 files changed

+59
-24
lines changed

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Dialog/FluentDialog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ It is then retrieved in the `DialogResult` like in the example below.
7272
}
7373
```
7474

75-
> **Note:**
75+
> [!NOTE]
7676
> 1. The `FluentDialogBody` component is required to display the dialog window correctly.
7777
> 2. ⚠️ If you override the `OnInitializedAsync` method, **you must call** the `base.OnInitializedAsync()` method,
7878
> in addition to your personalized code.

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Dialog/FluentDrawer.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Once the user closes the dialog window, the `ShowDrawerAsync` method returns a `
2323

2424
👉 See the [Dialog](/Dialog) documentation for more information.
2525

26-
> **Note:** The `ShowDrawerAsync` method is identical to the `ShowDialogAsync` method.
26+
> [!NOTE]
27+
> The `ShowDrawerAsync` method is identical to the `ShowDialogAsync` method.
2728
> With the exception of the **default value** of the `options.Alignment` property, which is `DialogAlignment.End`.
2829
> And the resulting HTML code is slightly different, using a `fluent-drawer` instead of a `fluent-dialog`.
2930
> The visual rendering and animation of opening and closing is also different.

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Field/FluentField.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ the default text and icon (or add an icon in the case of `MessageState = null`).
6464

6565
{{ FieldStatesExample }}
6666

67-
⚠️ **Note** that the `MessageCondition` attribute must be set to
67+
[!NOTE] that the `MessageCondition` attribute must be set to
6868
`(i) => true` or identical to `FluentFieldCondition.Always`.
6969
This enables the message to be displayed, which is not the case by default.
7070

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Layout/FluentLayout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ using the [@container](https://developer.mozilla.org/en-US/docs/Web/CSS/@contain
4242

4343
Each time the breakpoint is reached, the layout will be updated to reflect the new layout, and the event `OnBreakpointEnter` will be triggered.
4444

45-
**💡 Note**: The `FluentLayout` component can be used with a Blazor static web app or a Blazor interactive app.
45+
[!TIP] The `FluentLayout` component can be used with a Blazor static web app or a Blazor interactive app.
4646
The hamburger menu is available in all modes, but the event `OnBreakpointEnter` and the `MenuDeferredLoading` parameter are only available in "interactive mode".
4747

4848
## Sticky Panels

examples/Demo/FluentUI.Demo.Client/Documentation/Components/Tabs/FluentTabs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and require less scrolling.
1313
For navigation beyond closely related categories, use a [FluentLink](/link) instead.
1414
To initiate an action, use a [FluentButton](/button) instead.
1515

16-
> **note**: For the moment, there are no 'scrolling' functions when the number of tabs is too large
16+
> [!NOTE] For the moment, there are no 'scrolling' functions when the number of tabs is too large
1717
> in relation to the size of the container or screen.
1818
1919
## Default

examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Localization.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ Here's a step-by-step guide:
4444
}
4545
```
4646

47-
> **Note:**
48-
>
47+
> [!NOTE]
4948
> The list of keys can be found in the `Core\Microsoft.FluentUI.AspNetCore.Components\Localization\LanguageResource.resx` file.
5049
> Or you can use a constant from the `Microsoft.FluentUI.AspNetCore.Components.Localization.LanguageResource` class.
5150
> Example: `Localization.LanguageResource.MessageBox_ButtonOk`.

examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Migration/CopilotInstructionsContent.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Example benefits:
1212
- Migrate complete file following new namespacing and new parameters
1313
- Renaming old names from v3-v4 to v5
1414

15-
> ⚠️ Note
16-
>
15+
> [!NOTE]
1716
> - This feature is currently in public preview and is subject to change.
1817
> - Custom instructions are currently only supported for **Copilot Chat** in **VS Code** and **Visual Studio**.
1918

examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Migration/MigrationFluentProgressRing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ hidden: true
77
The component itself has been renamed from `FluentProgressRing` to `FluentSpinner`
88
to be coherent with the Web Components and React naming conventions.
99

10-
> **Note:** The new component `FluentSpinner` cannot be paused. It must always be spinning.
10+
> [!NOTE] The new component `FluentSpinner` cannot be paused. It must always be spinning.
1111
> So, the `Paused`, `Min`, `Max`, `Value` properties has been removed.
1212
1313
### New properties

examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Styles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ If you are creating a site by using our [Templates package](https://www.fluentui
5454
this is already set up for you.
5555
You can <a href="/_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" target="_blank">download the file</a> to see what's inside.
5656

57-
> **Note**: It is entirely possible to build a site **without using Reboot** but you will have to do more styling yourself.
57+
> [!NOTE] It is entirely possible to build a site **without using Reboot** but you will have to do more styling yourself.
5858
5959
## Approach
6060

examples/Tools/FluentUI.Demo.DocViewer/Components/MarkdownViewer.razor.css

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,35 @@
5050
border-left: 6px solid var(--colorBrandBackground);
5151
}
5252

53-
/* Code */
53+
/* Keywords */
54+
.doc-viewer ::deep span[keyword] {
55+
font-weight: 600;
56+
display: flex;
57+
align-items: center;
58+
column-gap: 4px;
59+
}
60+
61+
.doc-viewer ::deep blockquote:has(span[keyword="note"]) {
62+
background-color: var(--colorBrandBackground2);
63+
border-left: 6px solid var(--colorBrandBackground);
64+
}
65+
66+
.doc-viewer ::deep blockquote:has(span[keyword="tip"]) {
67+
background-color: var(--colorPaletteDarkGreenBackground2);
68+
border-left: 6px solid var(--colorPaletteDarkGreenBorderActive);
69+
}
70+
71+
.doc-viewer ::deep blockquote:has(span[keyword="warn"]) {
72+
background-color: var(--colorPaletteGoldBackground2);
73+
border-left: 6px solid var(--colorPaletteGoldBorderActive);
74+
}
5475

76+
.doc-viewer ::deep span[keyword] svg {
77+
fill: var(--colorNeutralForeground1);
78+
width: 20px;
79+
height: 20px;
80+
}
81+
/* Code */
5582
.doc-viewer ::deep code {
5683
font-weight: 500;
5784
background-color: var(--colorNeutralBackground5);
@@ -87,9 +114,7 @@
87114
.doc-viewer ::deep pre code[source][class*="hljs"] {
88115
display: block;
89116
}
90-
91117
/* Demo Section */
92-
93118
.doc-viewer ::deep .demo-tabs {
94119
min-height: 100px;
95120
}
@@ -100,9 +125,7 @@
100125
padding: 16px 16px;
101126
margin: 8px 0px;
102127
}
103-
104128
/* API Summary */
105-
106129
.doc-viewer ::deep .api-summary {
107130
background-color: var(--colorNeutralBackground4);
108131
max-width: calc(100vw - 32px);
@@ -112,9 +135,7 @@
112135
.doc-viewer ::deep .api-summary * {
113136
margin: 0px;
114137
}
115-
116138
/* API table */
117-
118139
.doc-viewer ::deep .api-table {
119140
width: 100%;
120141
max-width: calc(100vw - 32px);
@@ -170,7 +191,6 @@
170191
width: 20px;
171192
height: 20px;
172193
}
173-
174194
/* No Columns, for Methods view (same styles as Mobile */
175195
.doc-viewer ::deep .api-table[no-col] tr {
176196
display: flex;
@@ -179,8 +199,7 @@
179199
margin-bottom: 10px;
180200
}
181201

182-
.doc-viewer ::deep .api-table[no-col] td,
183-
.doc-viewer ::deep .api-table[no-col] th {
202+
.doc-viewer ::deep .api-table[no-col] td, .doc-viewer ::deep .api-table[no-col] th {
184203
display: none;
185204
flex-wrap: wrap;
186205
white-space: normal;
@@ -204,9 +223,7 @@
204223
display: block;
205224
margin-left: 24px;
206225
}
207-
208226
/* Mobile */
209-
210227
@media(max-width: 768px) {
211228

212229
.doc-viewer ::deep .api-table tr {

examples/Tools/FluentUI.Demo.DocViewer/Models/Section.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public Task<Section> ReadAsync(string content)
133133
// Text / HTML section
134134
else
135135
{
136-
Value = content;
136+
Value = ReplaceMarkupKeyWord(content);
137137
Type = SectionType.Html;
138138
Arguments = new Dictionary<string, string>();
139139
}
@@ -173,4 +173,23 @@ private static (string Name, Dictionary<string, string> Arguments) ParseComponen
173173

174174
return (componentName, dict);
175175
}
176+
177+
/// <summary />
178+
private static string ReplaceMarkupKeyWord(string content)
179+
{
180+
const string NOTE_ICON = "<svg viewBox=\"0 0 16 16\"><path d=\"M8 2a6 6 0 1 1 0 12A6 6 0 0 1 8 2Zm0 1a5 5 0 1 0 0 10A5 5 0 0 0 8 3Zm0 7a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5Zm0-5.5a.5.5 0 0 1 .5.41V8.5a.5.5 0 0 1-1 .09V5c0-.28.22-.5.5-.5Z\" /></svg>";
181+
const string WARN_ICON = NOTE_ICON;
182+
const string TIP_ICON = "<svg viewBox=\"0 0 16 16\"><path d=\"M4.5 6.5A3.5 3.5 0 1 1 10.45 9c-.19.19-.36.43-.44.73L9.66 11H6.34l-.35-1.27c-.08-.3-.25-.54-.44-.73A3.49 3.49 0 0 1 4.5 6.5ZM6.6 12h2.8l-.18.63a.5.5 0 0 1-.48.37H7.26a.5.5 0 0 1-.48-.37L6.61 12ZM8 2a4.5 4.5 0 0 0-3.16 7.7c.1.1.16.2.19.3l.79 2.9c.17.65.77 1.1 1.44 1.1h1.48a1.5 1.5 0 0 0 1.44-1.1l.8-2.9c.02-.1.08-.2.18-.3A4.49 4.49 0 0 0 8 2Z\" /></svg>";
183+
184+
content = Regex.Replace(content, @"\[!NOTE\]", $"<span keyword=\"note\">{NOTE_ICON}Note</span>", RegexOptions.IgnoreCase);
185+
content = Regex.Replace(content, @"\[!NOTE_ICON\]", $"<span keyword=\"note\">{NOTE_ICON}</span>", RegexOptions.IgnoreCase);
186+
187+
content = Regex.Replace(content, @"\[!WARNING\]", $"<span keyword=\"warn\">{WARN_ICON}Warning</span>", RegexOptions.IgnoreCase);
188+
content = Regex.Replace(content, @"\[!WARNING_ICON\]", $"<span keyword=\"warn\">{WARN_ICON}</span>", RegexOptions.IgnoreCase);
189+
190+
content = Regex.Replace(content, @"\[!TIP\]", $"<span keyword=\"tip\">{TIP_ICON}Tip</span>", RegexOptions.IgnoreCase);
191+
content = Regex.Replace(content, @"\[!TIP_ICON\]", $"<span keyword=\"tip\">{TIP_ICON}</span>", RegexOptions.IgnoreCase);
192+
193+
return content;
194+
}
176195
}

0 commit comments

Comments
 (0)