fluent-svelte-extra 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/.prettierignore +1 -0
  2. package/.prettierrc +7 -0
  3. package/CHANGELOG.md +7 -0
  4. package/LICENSE +21 -0
  5. package/README.md +33 -0
  6. package/package.json +83 -0
  7. package/src/app.html +12 -0
  8. package/src/global.d.ts +1 -0
  9. package/src/lib/AutoSuggestBox/AutoSuggestBox.scss +44 -0
  10. package/src/lib/AutoSuggestBox/AutoSuggestBox.svelte +173 -0
  11. package/src/lib/Button/Button.scss +94 -0
  12. package/src/lib/Button/Button.svelte +48 -0
  13. package/src/lib/CalendarDatePicker/CalendarDatePicker.scss +15 -0
  14. package/src/lib/CalendarDatePicker/CalendarDatePicker.svelte +86 -0
  15. package/src/lib/CalendarView/CalendarView.scss +156 -0
  16. package/src/lib/CalendarView/CalendarView.svelte +753 -0
  17. package/src/lib/CalendarView/CalendarViewItem.scss +130 -0
  18. package/src/lib/CalendarView/CalendarViewItem.svelte +33 -0
  19. package/src/lib/Checkbox/Checkbox.scss +117 -0
  20. package/src/lib/Checkbox/Checkbox.svelte +81 -0
  21. package/src/lib/ComboBox/ComboBox.scss +152 -0
  22. package/src/lib/ComboBox/ComboBox.svelte +360 -0
  23. package/src/lib/ComboBox/ComboBoxItem.scss +80 -0
  24. package/src/lib/ComboBox/ComboBoxItem.svelte +30 -0
  25. package/src/lib/ContentDialog/ContentDialog.scss +68 -0
  26. package/src/lib/ContentDialog/ContentDialog.svelte +123 -0
  27. package/src/lib/ContextMenu/ContextMenu.scss +11 -0
  28. package/src/lib/ContextMenu/ContextMenu.svelte +104 -0
  29. package/src/lib/Expander/Expander.scss +134 -0
  30. package/src/lib/Expander/Expander.svelte +123 -0
  31. package/src/lib/Flipper/Flipper.svelte +49 -0
  32. package/src/lib/Flyout/FlyoutSurface.scss +14 -0
  33. package/src/lib/Flyout/FlyoutSurface.svelte +21 -0
  34. package/src/lib/Flyout/FlyoutWrapper.scss +81 -0
  35. package/src/lib/Flyout/FlyoutWrapper.svelte +126 -0
  36. package/src/lib/IconButton/IconButton.scss +31 -0
  37. package/src/lib/IconButton/IconButton.svelte +49 -0
  38. package/src/lib/InfoBadge/InfoBadge.scss +39 -0
  39. package/src/lib/InfoBadge/InfoBadge.svelte +81 -0
  40. package/src/lib/InfoBar/InfoBar.scss +122 -0
  41. package/src/lib/InfoBar/InfoBar.svelte +133 -0
  42. package/src/lib/ListItem/ListItem.scss +74 -0
  43. package/src/lib/ListItem/ListItem.svelte +88 -0
  44. package/src/lib/MenuBar/MenuBar.scss +10 -0
  45. package/src/lib/MenuBar/MenuBar.svelte +49 -0
  46. package/src/lib/MenuBar/MenuBarItem.scss +38 -0
  47. package/src/lib/MenuBar/MenuBarItem.svelte +135 -0
  48. package/src/lib/MenuBar/flyoutState.ts +5 -0
  49. package/src/lib/MenuFlyout/MenuFlyoutDivider.scss +7 -0
  50. package/src/lib/MenuFlyout/MenuFlyoutDivider.svelte +14 -0
  51. package/src/lib/MenuFlyout/MenuFlyoutItem.scss +147 -0
  52. package/src/lib/MenuFlyout/MenuFlyoutItem.svelte +239 -0
  53. package/src/lib/MenuFlyout/MenuFlyoutSurface.scss +42 -0
  54. package/src/lib/MenuFlyout/MenuFlyoutSurface.svelte +28 -0
  55. package/src/lib/MenuFlyout/MenuFlyoutWrapper.scss +64 -0
  56. package/src/lib/MenuFlyout/MenuFlyoutWrapper.svelte +114 -0
  57. package/src/lib/NavigationView/NavigationView.scss +0 -0
  58. package/src/lib/NavigationView/NavigationView.svelte +82 -0
  59. package/src/lib/NumberBox/NumberBox.scss +31 -0
  60. package/src/lib/NumberBox/NumberBox.svelte +267 -0
  61. package/src/lib/PersonPicture/PersonPicture.scss +35 -0
  62. package/src/lib/PersonPicture/PersonPicture.svelte +62 -0
  63. package/src/lib/ProgressBar/ProgressBar.scss +83 -0
  64. package/src/lib/ProgressBar/ProgressBar.svelte +60 -0
  65. package/src/lib/ProgressRing/ProgressRing.scss +37 -0
  66. package/src/lib/ProgressRing/ProgressRing.svelte +73 -0
  67. package/src/lib/RadioButton/RadioButton.scss +114 -0
  68. package/src/lib/RadioButton/RadioButton.svelte +67 -0
  69. package/src/lib/RangeSlider/RangeSlider.svelte +91 -0
  70. package/src/lib/ScrollView/ScrollView.svelte +9 -0
  71. package/src/lib/Slider/Slider.scss +263 -0
  72. package/src/lib/Slider/Slider.svelte +261 -0
  73. package/src/lib/TextBlock/TextBlock.scss +62 -0
  74. package/src/lib/TextBlock/TextBlock.svelte +70 -0
  75. package/src/lib/TextBox/TextBox.scss +108 -0
  76. package/src/lib/TextBox/TextBox.svelte +225 -0
  77. package/src/lib/TextBox/TextBoxButton.scss +34 -0
  78. package/src/lib/TextBox/TextBoxButton.svelte +27 -0
  79. package/src/lib/ToggleSwitch/ToggleSwitch.scss +118 -0
  80. package/src/lib/ToggleSwitch/ToggleSwitch.svelte +55 -0
  81. package/src/lib/Tooltip/TooltipSurface.scss +16 -0
  82. package/src/lib/Tooltip/TooltipSurface.svelte +27 -0
  83. package/src/lib/Tooltip/TooltipWrapper.scss +66 -0
  84. package/src/lib/Tooltip/TooltipWrapper.svelte +117 -0
  85. package/src/lib/_mixins.scss +130 -0
  86. package/src/lib/index.ts +33 -0
  87. package/src/lib/internal.ts +213 -0
  88. package/src/lib/svelte-jsx.d.ts +14 -0
  89. package/src/lib/theme.css +414 -0
  90. package/src/routes/__layout.svelte +48 -0
  91. package/src/routes/docs/__layout.svelte +122 -0
  92. package/src/routes/docs/components/button.md +43 -0
  93. package/src/routes/docs/components/calendarview.md +188 -0
  94. package/src/routes/docs/components/checkbox.md +87 -0
  95. package/src/routes/docs/components/contentdialog.md +155 -0
  96. package/src/routes/docs/components/expander.md +115 -0
  97. package/src/routes/docs/components/flyout.md +107 -0
  98. package/src/routes/docs/components/iconbutton.md +39 -0
  99. package/src/routes/docs/components/infobadge.md +54 -0
  100. package/src/routes/docs/components/infobar.md +102 -0
  101. package/src/routes/docs/components/listitem.md +87 -0
  102. package/src/routes/docs/components/personpicture.md +125 -0
  103. package/src/routes/docs/components/progressring.md +83 -0
  104. package/src/routes/docs/components/radiobutton.md +88 -0
  105. package/src/routes/docs/components/slider.md +165 -0
  106. package/src/routes/docs/components/textblock.md +46 -0
  107. package/src/routes/docs/components/textbox.md +124 -0
  108. package/src/routes/docs/components/toggleswitch.md +73 -0
  109. package/src/routes/docs/getting-started.md +116 -0
  110. package/src/routes/docs/index.md +37 -0
  111. package/src/routes/docs/internals/index.md +0 -0
  112. package/src/routes/index.svelte +121 -0
  113. package/src/routes/test/__layout-test.svelte +1 -0
  114. package/src/routes/test/index.svelte +757 -0
  115. package/src/routes/test/nav.svelte +7 -0
  116. package/src/site/data/docs.ts +176 -0
  117. package/src/site/data/home.ts +12 -0
  118. package/src/site/lib/APIDocs/APIDocs.svelte +178 -0
  119. package/src/site/lib/APIDocs/ParsedComponent.d.ts +85 -0
  120. package/src/site/lib/CopyBox/CopyBox.svelte +23 -0
  121. package/src/site/lib/Example/Example.scss +33 -0
  122. package/src/site/lib/Example/Example.svelte +18 -0
  123. package/src/site/lib/HeroCard/HeroCard.scss +24 -0
  124. package/src/site/lib/HeroCard/HeroCard.svelte +36 -0
  125. package/src/site/lib/Metadata/Metadata.svelte +14 -0
  126. package/src/site/lib/Navbar/Navbar.scss +92 -0
  127. package/src/site/lib/Navbar/Navbar.svelte +47 -0
  128. package/src/site/lib/PageSection/PageSection.scss +57 -0
  129. package/src/site/lib/PageSection/PageSection.svelte +10 -0
  130. package/src/site/lib/Showcase/Showcase.scss +53 -0
  131. package/src/site/lib/Showcase/Showcase.svelte +67 -0
  132. package/src/site/lib/Toc/Toc.scss +18 -0
  133. package/src/site/lib/Toc/Toc.svelte +59 -0
  134. package/src/site/lib/TreeView/TreeView.svelte +89 -0
  135. package/src/site/lib/index.ts +9 -0
  136. package/src/site/styles/_markdown.scss +260 -0
  137. package/src/site/styles/_mixins.scss +319 -0
  138. package/src/site/styles/global.scss +40 -0
  139. package/src/site/styles/pages/docs.scss +74 -0
  140. package/src/site/styles/pages/home.scss +134 -0
  141. package/static/bloom-mica-dark.png +0 -0
  142. package/static/bloom-mica-light.png +0 -0
  143. package/static/logo.svg +11 -0
  144. package/svelte.config.js +57 -0
  145. package/tsconfig.json +38 -0
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import { get_current_component } from "svelte/internal";
3
+ import { createEventForwarder } from "$lib/internal";
4
+
5
+ /** @restProps {button | a} */
6
+ /** Sets an href value and converts the button element into an anchor. */
7
+ export let href = "";
8
+
9
+ /** Controls whether the button is intended for user interaction, and styles it accordingly. */
10
+ export let disabled = false;
11
+
12
+ /** Specifies a custom class name for the button. */
13
+ let className = "";
14
+ export { className as class };
15
+
16
+ /** Obtains a bound DOM reference to the button or anchor element. */
17
+ export let element: HTMLElement = null;
18
+
19
+ const forwardEvents = createEventForwarder(get_current_component());
20
+ </script>
21
+
22
+ <!--
23
+ @component
24
+ An Icon Button is a clickable control that triggers an immediate action. Unlike the Button control, it serves the purpose of encapsulating an icon glyph as it’s content. [Docs](https://fluent-svelte.vercel.app/docs/components/iconbutton)
25
+ - Usage:
26
+ ```tsx
27
+ <IconButton>
28
+ <svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
29
+ <path d="M8 14A6 6 0 108 2a6 6 0 000 12zm0-1A5 5 0 118 3a5 5 0 010 10z" />
30
+ </svg>
31
+ </IconButton>
32
+ ```
33
+ -->
34
+ <svelte:element
35
+ this={href && !disabled ? "a" : "button"}
36
+ use:forwardEvents
37
+ bind:this={element}
38
+ role={href && !disabled ? "button" : undefined}
39
+ href={href && !disabled ? href : undefined}
40
+ class="icon-button {className}"
41
+ class:disabled
42
+ {...$$restProps}
43
+ >
44
+ <slot />
45
+ </svelte:element>
46
+
47
+ <style lang="scss">
48
+ @use "./IconButton";
49
+ </style>
@@ -0,0 +1,39 @@
1
+ @use "../mixins" as *;
2
+
3
+ .info-badge {
4
+ @include flex($inline: true, $align: center, $justify: center);
5
+ box-sizing: border-box;
6
+ user-select: none;
7
+ min-inline-size: 16px;
8
+ min-block-size: 16px;
9
+ border-radius: 16px;
10
+ padding: 2px 4px;
11
+ color: var(--text-on-accent-primary);
12
+ line-height: var(--caption-font-size);
13
+ font: {
14
+ family: var(--font-family-small);
15
+ size: var(--caption-font-size);
16
+ }
17
+ &.severity- {
18
+ &attention {
19
+ background-color: var(--system-attention);
20
+ }
21
+ &success {
22
+ background-color: var(--system-success);
23
+ }
24
+ &caution {
25
+ background-color: var(--system-caution);
26
+ }
27
+ &critical {
28
+ background-color: var(--system-critical);
29
+ }
30
+ &information {
31
+ background-color: var(--system-solid-neutral);
32
+ }
33
+ }
34
+ :global(svg) {
35
+ inline-size: 8px;
36
+ block-size: 8px;
37
+ fill: currentColor;
38
+ }
39
+ }
@@ -0,0 +1,81 @@
1
+ <script lang="ts">
2
+ import { createEventForwarder } from "fluent-svelte/internal";
3
+ import { get_current_component } from "svelte/internal";
4
+
5
+ /** Indicates the severity color of the badge. */
6
+ export let severity: "attention" | "success" | "caution" | "critical" | "information" =
7
+ "attention";
8
+
9
+ /** Specifies a custom class name for the badge. */
10
+ let className = "";
11
+ export { className as class };
12
+
13
+ /** Obtains a bound DOM reference to the badge's element. */
14
+ export let element: HTMLSpanElement = null;
15
+
16
+ const forwardEvents = createEventForwarder(get_current_component());
17
+ const svgProps = {
18
+ "aria-hidden": true,
19
+ xmlns: "http://www.w3.org/2000/svg"
20
+ };
21
+ </script>
22
+
23
+ <!--
24
+ @component
25
+ InfoBadges are a non-intrusive and intuitive way to display notifications or bring focus to an area within an app - whether that be for notifications, indicating new content, or showing an alert. [Docs](https://fluent-svelte.vercel.app/docs/components/infobadge)
26
+ - Usage:
27
+ ```tsx
28
+ <InfoBadge />
29
+ <InfoBadge severity="success" />
30
+ <InfoBadge>0</InfoBadge>
31
+ ```
32
+ -->
33
+ <span
34
+ use:forwardEvents
35
+ bind:this={element}
36
+ class="info-badge severity-{severity} {className}"
37
+ {...$$restProps}
38
+ >
39
+ <slot>
40
+ {#if severity === "attention"}
41
+ <svg {...svgProps} viewBox="162 118 701 789">
42
+ <path
43
+ fill="currentColor"
44
+ d="M862.5,680C862.5,687.333 861.083,694.25 858.25,700.75C855.417,707.25 851.583,712.917 846.75,717.75C841.917,722.583 836.25,726.417 829.75,729.25C823.25,732.083 816.333,733.5 809,733.5C800,733.5 791.333,731.167 783,726.5L565.5,603.5L565.5,853.5C565.5,860.833 564.083,867.75 561.25,874.25C558.417,880.75 554.583,886.333 549.75,891C544.917,895.667 539.25,899.417 532.75,902.25C526.25,905.083 519.333,906.5 512,906.5C504.667,906.5 497.75,905.083 491.25,902.25C484.75,899.417 479.083,895.667 474.25,891C469.417,886.333 465.583,880.75 462.75,874.25C459.917,867.75 458.5,860.833 458.5,853.5L458.5,603.5L241,726.5C232.667,731.167 224,733.5 215,733.5C207.667,733.5 200.75,732.083 194.25,729.25C187.75,726.417 182.083,722.583 177.25,717.75C172.417,712.917 168.583,707.25 165.75,700.75C162.917,694.25 161.5,687.333 161.5,680C161.5,670.667 164,661.75 169,653.25C174,644.75 180.5,638.167 188.5,633.5L403.5,512L188.5,390.5C180.5,385.833 174,379.25 169,370.75C164,362.25 161.5,353.333 161.5,344C161.5,336.667 162.917,329.75 165.75,323.25C168.583,316.75 172.417,311.083 177.25,306.25C182.083,301.417 187.75,297.583 194.25,294.75C200.75,291.917 207.667,290.5 215,290.5C224.667,290.5 233.333,292.833 241,297.5L458.5,420.5L458.5,170.5C458.5,163.167 459.917,156.25 462.75,149.75C465.583,143.25 469.417,137.667 474.25,133C479.083,128.333 484.75,124.583 491.25,121.75C497.75,118.917 504.667,117.5 512,117.5C519.333,117.5 526.25,118.917 532.75,121.75C539.25,124.583 544.917,128.333 549.75,133C554.583,137.667 558.417,143.25 561.25,149.75C564.083,156.25 565.5,163.167 565.5,170.5L565.5,420.5L783,297.5C791.333,292.833 800,290.5 809,290.5C816.333,290.5 823.25,291.917 829.75,294.75C836.25,297.583 841.917,301.417 846.75,306.25C851.583,311.083 855.417,316.75 858.25,323.25C861.083,329.75 862.5,336.667 862.5,344C862.5,353.333 860,362.25 855,370.75C850,379.25 843.5,385.833 835.5,390.5L620.5,512L835.5,633.5C843.5,638.167 850,644.75 855,653.25C860,661.75 862.5,670.667 862.5,680Z"
45
+ />
46
+ </svg>
47
+ {:else if severity === "success"}
48
+ <svg {...svgProps} viewBox="118 245 790 577">
49
+ <path
50
+ fill="currentColor"
51
+ d="M117.5,554.5C117.5,547.167 118.917,540.25 121.75,533.75C124.583,527.25 128.417,521.583 133.25,516.75C138.083,511.917 143.75,508.083 150.25,505.25C156.75,502.417 163.667,501 171,501C185.333,501 197.833,506.333 208.5,517L384,692.5L815.5,261C826.167,250.333 838.833,245 853.5,245C860.833,245 867.75,246.417 874.25,249.25C880.75,252.083 886.417,256 891.25,261C896.083,266 899.917,271.75 902.75,278.25C905.583,284.75 907,291.5 907,298.5C907,313.167 901.667,325.833 891,336.5L421.5,805.5C416.5,810.5 410.75,814.417 404.25,817.25C397.75,820.083 391,821.5 384,821.5C369.667,821.5 357.167,816.167 346.5,805.5L133,592.5C122.667,582.167 117.5,569.5 117.5,554.5Z"
52
+ />
53
+ </svg>
54
+ {:else if severity === "caution"}
55
+ <svg {...svgProps} viewBox="406 86 213 875">
56
+ <path
57
+ fill="currentColor"
58
+ d="M426.5,512L426.5,170.5C426.5,158.833 428.75,147.833 433.25,137.5C437.75,127.167 443.917,118.167 451.75,110.5C459.583,102.833 468.667,96.75 479,92.25C489.333,87.75 500.333,85.5 512,85.5C523.667,85.5 534.667,87.75 545,92.25C555.333,96.75 564.417,102.833 572.25,110.5C580.083,118.167 586.25,127.167 590.75,137.5C595.25,147.833 597.5,158.833 597.5,170.5L597.5,512C597.5,523.667 595.25,534.667 590.75,545C586.25,555.333 580.083,564.417 572.25,572.25C564.417,580.083 555.333,586.25 545,590.75C534.667,595.25 523.667,597.5 512,597.5C500.333,597.5 489.333,595.25 479,590.75C468.667,586.25 459.583,580.083 451.75,572.25C443.917,564.417 437.75,555.333 433.25,545C428.75,534.667 426.5,523.667 426.5,512ZM405.5,853.5C405.5,838.833 408.333,825 414,812C419.667,799 427.333,787.667 437,778C446.667,768.333 457.917,760.667 470.75,755C483.583,749.333 497.333,746.5 512,746.5C526.667,746.5 540.417,749.333 553.25,755C566.083,760.667 577.333,768.333 587,778C596.667,787.667 604.333,799 610,812C615.667,825 618.5,838.833 618.5,853.5C618.5,868.167 615.667,881.917 610,894.75C604.333,907.583 596.667,918.833 587,928.5C577.333,938.167 566,945.833 553,951.5C540,957.167 526.333,960 512,960C497.333,960 483.583,957.167 470.75,951.5C457.917,945.833 446.667,938.167 437,928.5C427.333,918.833 419.667,907.583 414,894.75C408.333,881.917 405.5,868.167 405.5,853.5Z"
59
+ />
60
+ </svg>
61
+ {:else if severity === "critical"}
62
+ <svg {...svgProps} viewBox="172 171 683 683">
63
+ <path
64
+ fill="currentColor"
65
+ d="M512.5,587.5L262.5,838C252.167,848.333 239.5,853.5 224.5,853.5C209.5,853.5 196.917,848.417 186.75,838.25C176.583,828.083 171.5,815.5 171.5,800.5C171.5,785.5 176.667,772.833 187,762.5L437,512L187,262C176.667,251.667 171.5,239.167 171.5,224.5C171.5,217.167 172.833,210.167 175.5,203.5C178.167,196.833 181.917,191.167 186.75,186.5C191.583,181.833 197.167,178.083 203.5,175.25C209.833,172.417 216.833,171 224.5,171C239.167,171 251.667,176.167 262,186.5L512.5,437L762.5,186.5C773.167,175.833 785.833,170.5 800.5,170.5C807.833,170.5 814.75,171.917 821.25,174.75C827.75,177.583 833.417,181.417 838.25,186.25C843.083,191.083 846.833,196.75 849.5,203.25C852.167,209.75 853.5,216.667 853.5,224C853.5,238.667 848.333,251.167 838,261.5L587.5,512L838,762.5C848.667,773.167 854,785.833 854,800.5C854,807.833 852.583,814.667 849.75,821C846.917,827.333 843.083,832.917 838.25,837.75C833.417,842.583 827.75,846.417 821.25,849.25C814.75,852.083 807.833,853.5 800.5,853.5C785.5,853.5 772.833,848.333 762.5,838Z"
66
+ />
67
+ </svg>
68
+ {:else if severity === "information"}
69
+ <svg {...svgProps} viewBox="406 64 213 875">
70
+ <path
71
+ fill="currentColor"
72
+ d="M405.5,170.5C405.5,156.167 408.333,142.5 414,129.5C419.667,116.5 427.333,105.167 437,95.5C446.667,85.8334 457.917,78.1667 470.75,72.5C483.583,66.8334 497.333,64.0001 512,64C526.333,64.0001 540,66.8334 553,72.5C566,78.1667 577.333,85.8334 587,95.5C596.667,105.167 604.333,116.5 610,129.5C615.667,142.5 618.5,156.167 618.5,170.5C618.5,185.167 615.667,199 610,212C604.333,225 596.667,236.333 587,246C577.333,255.667 566.083,263.333 553.25,269C540.417,274.667 526.667,277.5 512,277.5C497.333,277.5 483.583,274.667 470.75,269C457.917,263.333 446.667,255.667 437,246C427.333,236.333 419.667,225 414,212C408.333,199 405.5,185.167 405.5,170.5ZM426.5,853.5L426.5,512C426.5,500.333 428.75,489.333 433.25,479C437.75,468.667 443.917,459.583 451.75,451.75C459.583,443.917 468.667,437.75 479,433.25C489.333,428.75 500.333,426.5 512,426.5C523.667,426.5 534.667,428.75 545,433.25C555.333,437.75 564.417,443.917 572.25,451.75C580.083,459.583 586.25,468.667 590.75,479C595.25,489.333 597.5,500.333 597.5,512L597.5,853.5C597.5,865.167 595.25,876.167 590.75,886.5C586.25,896.833 580.083,905.833 572.25,913.5C564.417,921.167 555.333,927.25 545,931.75C534.667,936.25 523.667,938.5 512,938.5C500.333,938.5 489.333,936.25 479,931.75C468.667,927.25 459.583,921.167 451.75,913.5C443.917,905.833 437.75,896.833 433.25,886.5C428.75,876.167 426.5,865.167 426.5,853.5Z"
73
+ />
74
+ </svg>
75
+ {/if}
76
+ </slot>
77
+ </span>
78
+
79
+ <style lang="scss">
80
+ @use "./InfoBadge";
81
+ </style>
@@ -0,0 +1,122 @@
1
+ @use "../mixins" as *;
2
+
3
+ .info-bar {
4
+ @include flex($align: center);
5
+ position: relative;
6
+ min-block-size: 48px;
7
+ padding-inline-start: 15px;
8
+ box-sizing: border-box;
9
+ user-select: none;
10
+ background-clip: padding-box;
11
+ font-family: var(--font-family-text);
12
+ border: 1px solid var(--card-stroke-default);
13
+ border-radius: var(--control-corner-radius);
14
+ &.severity- {
15
+ &information {
16
+ background-color: var(--card-background-secondary);
17
+ }
18
+ &success {
19
+ background-color: var(--system-background-success);
20
+ }
21
+ &caution {
22
+ background-color: var(--system-background-caution);
23
+ }
24
+ &critical {
25
+ background-color: var(--system-background-critical);
26
+ }
27
+ &attention {
28
+ background-color: var(--system-background-attention);
29
+ }
30
+ }
31
+ &-icon {
32
+ align-self: flex-start;
33
+ display: flex;
34
+ flex: 0 0 auto;
35
+ margin: {
36
+ block-start: 16px;
37
+ }
38
+ }
39
+ &-content {
40
+ @include flex($align: center, $wrap: true);
41
+ position: relative;
42
+ box-sizing: border-box;
43
+ flex: 1 1 auto;
44
+ margin: {
45
+ inline-start: 13px;
46
+ block-start: 7px;
47
+ block-end: 7px;
48
+ }
49
+ &.message-wrapped,
50
+ &.action-wrapped {
51
+ margin: {
52
+ block-start: 13px;
53
+ block-end: 15px;
54
+ }
55
+ }
56
+ &.message-wrapped {
57
+ h5,
58
+ p {
59
+ align-self: flex-start;
60
+ }
61
+ .info-bar-action {
62
+ margin-inline-end: 50%;
63
+ }
64
+ }
65
+ &.action-wrapped .info-bar-action {
66
+ padding-block-start: 16px;
67
+ }
68
+ }
69
+ h5,
70
+ p {
71
+ color: var(--text-primary);
72
+ margin: 0;
73
+ line-height: 20px;
74
+ font: {
75
+ size: var(--body-font-size);
76
+ weight: 400;
77
+ }
78
+ }
79
+ h5 {
80
+ font-weight: 600;
81
+ margin-inline-end: 12px;
82
+ }
83
+ p {
84
+ flex: 1 1 auto;
85
+ margin-inline-end: 15px;
86
+ }
87
+ &-action {
88
+ @include flex($align: center);
89
+ align-self: flex-start;
90
+ margin-inline-end: 4px;
91
+ }
92
+ &-close-button {
93
+ @include flex($align: center, $justify: center);
94
+ align-self: flex-start;
95
+ flex: 0 0 auto;
96
+ border: none;
97
+ outline: none;
98
+ appearance: none;
99
+ inline-size: 38px;
100
+ block-size: 38px;
101
+ margin: 4px;
102
+ color: var(--text-primary);
103
+ border-radius: var(--control-corner-radius);
104
+ background-color: var(--subtle-fill-transparent);
105
+ transition: var(--control-fast-duration) var(--control-fast-out-slow-in-easing);
106
+ &:focus-visible {
107
+ box-shadow: var(--focus-stroke);
108
+ }
109
+ &:hover {
110
+ background-color: var(--subtle-fill-secondary);
111
+ }
112
+ &:active {
113
+ color: var(--text-secondary);
114
+ background-color: var(--subtle-fill-tertiary);
115
+ }
116
+ svg {
117
+ inline-size: 12px;
118
+ block-size: 12px;
119
+ fill: currentColor;
120
+ }
121
+ }
122
+ }
@@ -0,0 +1,133 @@
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from "svelte";
3
+ import { get_current_component } from "svelte/internal";
4
+ import { createEventForwarder } from "$lib/internal";
5
+
6
+ import InfoBadge from "../InfoBadge/InfoBadge.svelte";
7
+
8
+ /** Determines whether the bar is open (rendered). */
9
+ export let open = true;
10
+
11
+ /** Determines whether the close button is used or not. */
12
+ export let closable = true;
13
+
14
+ /** Indicates the severity color of the bar. */
15
+ export let severity: "information" | "success" | "caution" | "critical" | "attention" =
16
+ "information";
17
+
18
+ /** Title of the Infobar. */
19
+ export let title = "";
20
+
21
+ /** Description text shown next to or below the title. */
22
+ export let message = "";
23
+
24
+ /** Specifies a custom class name for the bar. */
25
+ let className = "";
26
+ export { className as class };
27
+
28
+ /** Obtains a bound DOM reference to the bar's container element. */
29
+ export let element: HTMLDivElement = null;
30
+
31
+ /** Obtains a bound DOM reference to the bar's title element. */
32
+ export let titleElement: HTMLHeadingElement = null;
33
+
34
+ /** Obtains a bound DOM reference to the bar's message (paragraph) element. */
35
+ export let messageElement: HTMLParagraphElement = null;
36
+
37
+ /** Obtains a bound DOM reference to the bar's action wrapper element. */
38
+ export let actionElement: HTMLDivElement = null;
39
+
40
+ /** Obtains a bound DOM reference to the bar's close button element. */
41
+ export let closeButtonElement: HTMLButtonElement = null;
42
+
43
+ let wrapped = false;
44
+ let clientHeight = 0;
45
+
46
+ const dispatch = createEventDispatcher();
47
+ const forwardEvents = createEventForwarder(get_current_component());
48
+
49
+ $: actionWrapped = clientHeight && actionElement?.offsetTop > 0;
50
+ $: messageWrapped = clientHeight && messageElement?.offsetTop > titleElement?.offsetTop;
51
+ $: if (open) {
52
+ dispatch("open");
53
+ } else {
54
+ dispatch("close");
55
+ }
56
+ </script>
57
+
58
+ <!--
59
+ @component
60
+ The InfoBar control is for displaying app-wide status messages to users that are highly visible yet non-intrusive. There are built-in security levels to easily indicate the type of message shown as well as the option to include your own call to action or hyperlink button. [Docs](https://fluent-svelte.vercel.app/docs/components/infobar)
61
+ - Usage:
62
+ ```tsx
63
+ <InfoBar title="Title" message="Message">
64
+ <Button slot="action">Action</Button>
65
+ </InfoBar>
66
+ ```
67
+ -->
68
+ {#if open}
69
+ <div
70
+ use:forwardEvents
71
+ bind:this={element}
72
+ bind:clientHeight
73
+ class="info-bar severity-{severity} {className}"
74
+ role="alert"
75
+ {...$$restProps}
76
+ >
77
+ <div class="info-bar-icon">
78
+ <slot name="icon">
79
+ <InfoBadge {severity} />
80
+ </slot>
81
+ </div>
82
+ <div
83
+ class="info-bar-content"
84
+ class:wrapped
85
+ class:action-visible={$$slots.action}
86
+ class:action-wrapped={actionWrapped}
87
+ class:message-wrapped={messageWrapped}
88
+ >
89
+ {#if title}
90
+ <h5 bind:this={titleElement}>
91
+ {title}
92
+ </h5>
93
+ {/if}
94
+ {#if message || $$slots.default}
95
+ <p bind:this={messageElement}>
96
+ {message}
97
+ <slot />
98
+ </p>
99
+ {/if}
100
+ {#if $$slots.action}
101
+ <div class="info-bar-action" bind:this={actionElement}>
102
+ <slot name="action" />
103
+ </div>
104
+ {/if}
105
+ </div>
106
+ {#if closable}
107
+ <button
108
+ class="info-bar-close-button"
109
+ type="button"
110
+ aria-label="Close"
111
+ on:click={() => (open = false)}
112
+ bind:this={closeButtonElement}
113
+ >
114
+ <svg
115
+ aria-hidden="true"
116
+ xmlns="http://www.w3.org/2000/svg"
117
+ width="12"
118
+ height="12"
119
+ viewBox="0 0 1024 1024"
120
+ >
121
+ <path
122
+ fill="currentColor"
123
+ d="M512,584.5L87.5,1009C77.5,1019 65.5,1024 51.5,1024C36.8333,1024 24.5833,1019.08 14.75,1009.25C4.91667,999.417 0,987.167 0,972.5C0,958.5 5,946.5 15,936.5L439.5,512L15,87.5C5,77.5 0,65.3334 0,51C0,44 1.33333,37.3334 4,31C6.66667,24.6667 10.3333,19.25 15,14.75C19.6667,10.25 25.1667,6.66669 31.5,4C37.8333,1.33337 44.5,0 51.5,0C65.5,0 77.5,5 87.5,15L512,439.5L936.5,15C946.5,5 958.667,0 973,0C980,0 986.583,1.33337 992.75,4C998.917,6.66669 1004.33,10.3334 1009,15C1013.67,19.6667 1017.33,25.0834 1020,31.25C1022.67,37.4167 1024,44 1024,51C1024,65.3334 1019,77.5 1009,87.5L584.5,512L1009,936.5C1019,946.5 1024,958.5 1024,972.5C1024,979.5 1022.67,986.167 1020,992.5C1017.33,998.833 1013.75,1004.33 1009.25,1009C1004.75,1013.67 999.333,1017.33 993,1020C986.667,1022.67 980,1024 973,1024C958.667,1024 946.5,1019 936.5,1009Z"
124
+ />
125
+ </svg>
126
+ </button>
127
+ {/if}
128
+ </div>
129
+ {/if}
130
+
131
+ <style lang="scss">
132
+ @use "./InfoBar";
133
+ </style>
@@ -0,0 +1,74 @@
1
+ @use "../mixins" as *;
2
+
3
+ .list-item {
4
+ @include flex($align: center);
5
+
6
+ inline-size: calc(100% - 10px);
7
+ position: relative;
8
+ box-sizing: border-box;
9
+ flex: 0 0 auto;
10
+ margin: 3px 5px;
11
+ padding-inline: 12px;
12
+ border-radius: var(--control-corner-radius);
13
+ outline: none;
14
+ background-color: var(--subtle-fill-transparent);
15
+ color: var(--text-primary);
16
+ text-decoration: none;
17
+ cursor: default;
18
+ user-select: none;
19
+ block-size: 34px;
20
+ text-decoration: none;
21
+
22
+ &::before {
23
+ content: "";
24
+ position: absolute;
25
+ border-radius: 3px;
26
+ background-color: var(--accent-default);
27
+ transition: transform var(--control-fast-duration) var(--control-fast-out-slow-in-easing);
28
+ opacity: 0;
29
+ inset-inline-start: 0;
30
+ inline-size: 3px;
31
+ block-size: 16px;
32
+ transform: scaleY(0);
33
+ }
34
+
35
+ &.selected::before {
36
+ transform: scaleY(1);
37
+ opacity: 1;
38
+ }
39
+
40
+ &:focus-visible {
41
+ box-shadow: var(--focus-stroke);
42
+ }
43
+
44
+ &:hover,
45
+ &.selected {
46
+ background-color: var(--subtle-fill-secondary);
47
+ }
48
+
49
+ &:active {
50
+ background-color: var(--subtle-fill-tertiary);
51
+ color: var(--text-secondary);
52
+
53
+ &::before {
54
+ transform: scaleY(0.625);
55
+ }
56
+ }
57
+
58
+ &.disabled {
59
+ background-color: var(--subtle-fill-transparent);
60
+ color: var(--text-disabled);
61
+ pointer-events: none;
62
+ &.selected {
63
+ background-color: var(--subtle-fill-secondary);
64
+ &::before {
65
+ background-color: var(--accent-disabled);
66
+ }
67
+ }
68
+ }
69
+
70
+ > :global(svg) {
71
+ @include icon($size: 16px);
72
+ margin-inline-end: 16px;
73
+ }
74
+ }
@@ -0,0 +1,88 @@
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from "svelte";
3
+ import { get_current_component } from "svelte/internal";
4
+ import { createEventForwarder } from "$lib/internal";
5
+
6
+ import TextBlock from "../TextBlock/TextBlock.svelte";
7
+
8
+ /** @restProps {button | a} */
9
+ /** Controls whether the item is selected or not. */
10
+ export let selected = false;
11
+
12
+ /** Controls whether the item is intended for user interaction, and styles it accordingly. */
13
+ export let disabled = false;
14
+
15
+ /** Sets an href value and converts the list element into an anchor. */
16
+ export let href = "";
17
+
18
+ /** Specifies an ARIA role for the item. */
19
+ export let role = "listitem";
20
+
21
+ /** Specifies a custom class name for the item. */
22
+ let className = "";
23
+ export { className as class };
24
+
25
+ /** Obtains a bound DOM reference to the item's element. */
26
+ export let element: HTMLAnchorElement | HTMLLIElement = null;
27
+
28
+ const forwardEvents = createEventForwarder(get_current_component(), ["select"]);
29
+ const dispatch = createEventDispatcher();
30
+
31
+ $: if (selected) dispatch("select");
32
+
33
+ function handleKeyDown({ key, target }) {
34
+ if (key === "Enter") target.click();
35
+ }
36
+ </script>
37
+
38
+ <!--
39
+ @component
40
+ List Items display data stacked vertically in a single column. List Items work better for items that have text as a focal point, and for collections that are meant to be read top to bottom (i.e. alphabetically ordered). A few common use cases for List Items include lists of messages and search results. [Docs](https://fluent-svelte.vercel.app/docs/components/listitem)
41
+ - Usage:
42
+ ```tsx
43
+ <ListItem>Text</ListItem>
44
+ ```
45
+ -->
46
+ {#if href && !disabled}
47
+ <a
48
+ use:forwardEvents
49
+ on:keydown={handleKeyDown}
50
+ bind:this={element}
51
+ tabindex={disabled ? -1 : 0}
52
+ aria-selected={selected}
53
+ class="list-item {className}"
54
+ class:selected
55
+ class:disabled
56
+ {href}
57
+ {role}
58
+ {...$$restProps}
59
+ >
60
+ <slot name="icon" />
61
+ <TextBlock>
62
+ <slot />
63
+ </TextBlock>
64
+ </a>
65
+ {:else}
66
+ <li
67
+ use:forwardEvents
68
+ on:keydown={handleKeyDown}
69
+ bind:this={element}
70
+ tabindex={disabled ? -1 : 0}
71
+ aria-selected={selected}
72
+ class="list-item {className}"
73
+ class:selected
74
+ class:disabled
75
+ {href}
76
+ {role}
77
+ {...$$restProps}
78
+ >
79
+ <slot name="icon" />
80
+ <TextBlock>
81
+ <slot />
82
+ </TextBlock>
83
+ </li>
84
+ {/if}
85
+
86
+ <style lang="scss">
87
+ @use "./ListItem";
88
+ </style>
@@ -0,0 +1,10 @@
1
+ @use "../mixins" as *;
2
+
3
+ .menu-bar {
4
+ @include flex($align: center);
5
+ cursor: default;
6
+ user-select: none;
7
+ block-size: 40px;
8
+ margin: 0;
9
+ padding: 0;
10
+ }
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import { setContext } from "svelte";
3
+
4
+ import { isTabbable } from "tabbable";
5
+
6
+ /** Specifies a custom class name for the bar. */
7
+ let className = "";
8
+ export { className as class };
9
+
10
+ /** Obtains a bound DOM reference to the bar's outer container element. */
11
+ export let element: HTMLUListElement = null;
12
+
13
+ setContext("sideNavigation", (event, activeItem: HTMLElement) => {
14
+ const { key } = event;
15
+
16
+ let tabOrder: HTMLElement[] = [];
17
+
18
+ for (const child of Array.from(element.children)) {
19
+ if (isTabbable(child)) tabOrder.push(<HTMLElement>child);
20
+ }
21
+
22
+ const activeIndex = tabOrder.indexOf(activeItem);
23
+
24
+ if (tabOrder.length < 0) return;
25
+ if (key === "ArrowLeft" || key === "ArrowRight") event.preventDefault();
26
+
27
+ if (key === "ArrowLeft") {
28
+ if (tabOrder[0] === activeItem) {
29
+ tabOrder[tabOrder.length - 1].focus();
30
+ } else if (tabOrder.includes(<HTMLElement>activeItem)) {
31
+ tabOrder[activeIndex - 1].focus();
32
+ }
33
+ } else if (key === "ArrowRight") {
34
+ if (tabOrder[tabOrder.length - 1] === activeItem) {
35
+ tabOrder[0].focus();
36
+ } else if (tabOrder.includes(<HTMLElement>activeItem)) {
37
+ tabOrder[activeIndex + 1].focus();
38
+ }
39
+ }
40
+ });
41
+ </script>
42
+
43
+ <ul class="menu-bar {className}" role="menubar" bind:this={element} {...$$restProps}>
44
+ <slot />
45
+ </ul>
46
+
47
+ <style lang="scss">
48
+ @use "./MenuBar";
49
+ </style>
@@ -0,0 +1,38 @@
1
+ @use "../mixins" as *;
2
+
3
+ .menu-bar-item {
4
+ @include typography-body;
5
+ @include flex($inline: true, $align: center);
6
+
7
+ position: relative;
8
+ padding: 5px 11px;
9
+ margin: 4px;
10
+ cursor: default;
11
+ color: var(--text-primary);
12
+ background-color: var(--subtle-fill-transparent);
13
+ border-radius: var(--control-corner-radius);
14
+ &:hover {
15
+ background-color: var(--subtle-fill-secondary);
16
+ }
17
+ &:active,
18
+ &[aria-expanded="true"] {
19
+ background-color: var(--subtle-fill-tertiary);
20
+ &:hover {
21
+ background-color: var(--subtle-fill-secondary);
22
+ }
23
+ }
24
+ &:active {
25
+ color: var(--text-secondary);
26
+ }
27
+ &.disabled {
28
+ color: var(--text-disabled);
29
+ background-color: var(--subtle-fill-disabled) !important;
30
+ }
31
+ }
32
+
33
+ .menu-flyout-anchor {
34
+ z-index: 10000;
35
+ position: absolute;
36
+ inset-block-start: 100%;
37
+ inset-inline-start: 0;
38
+ }