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,165 @@
1
+ <script lang="ts">
2
+ import { Slider, Button, InfoBar } from "$lib";
3
+ import { Showcase, APIDocs } from "$site/lib";
4
+
5
+ import data from "$lib/Slider/Slider.svelte?sveld&raw";
6
+ </script>
7
+
8
+ A slider is a control that lets the user select from a range of values by moving a thumb control along a track.
9
+
10
+ ```ts
11
+ import { Slider } from "fluent-svelte";
12
+ ```
13
+
14
+ <Showcase columns={4} columnWidth="120px" repl="461bd056ac7b4c7a920354256560b0a4">
15
+ <div style="display: contents" on:mousedown|stopPropagation>
16
+ <Slider />
17
+ <Slider value={10000} step={10000} max={30000} ticks={[10000, 20000]} suffix="cm" />
18
+ <Slider value={80} max={200} reverse />
19
+ <Slider value={50} disabled />
20
+ <div style="block-size: 72px;">
21
+ <Slider orientation="vertical" value={24} />
22
+ </div>
23
+ <Slider orientation="vertical" value={50} reverse />
24
+ <Slider orientation="vertical" value={76} track={false} ticks={[24, 50, 76]} tickPlacement="after" />
25
+ <Slider orientation="vertical" value={24} disabled />
26
+ </div>
27
+ </Showcase>
28
+
29
+ ## Usage
30
+
31
+ ### Controlling Value
32
+
33
+ By default, sliders are created with a value of `0`. This starts the slider thumb at 0% of the track. You can set the initial value of the slider by setting the `value` property.
34
+
35
+ ```svelte example hideScript
36
+ <script>
37
+ import { Slider } from "fluent-svelte";
38
+ </script>
39
+
40
+ <Slider value={20} />
41
+ ```
42
+
43
+ Additionally, you can use svelte's two-way binding syntax to bind the value to a variable.
44
+
45
+ ```svelte example
46
+ <script>
47
+ import { Slider } from "fluent-svelte";
48
+
49
+ let value = 0;
50
+ </script>
51
+
52
+ <Slider bind:value />
53
+
54
+ Current value: {value}
55
+ ```
56
+
57
+ ### Minimum and Maximum Values
58
+
59
+ Sliders can normally only take in `value`s ranging from `0` to `100`. This can be changed by setting the `min` and `max` properties.
60
+
61
+ ```svelte example hideScript
62
+ <script>
63
+ import { Slider } from "fluent-svelte";
64
+ </script>
65
+
66
+ <Slider min={100} max={500} value={250} />
67
+ ```
68
+
69
+ ### Step
70
+
71
+ A `step` property can be set to control the granularity of the slider. For example, if you set the `step` to `10`, the slider will only allow values that are multiples of `10`. The default step of `1` means that the slider can take any whole-number value.
72
+
73
+ ```svelte example hideScript
74
+ <script>
75
+ import { Slider } from "fluent-svelte";
76
+ </script>
77
+
78
+ <Slider step={10} />
79
+ ```
80
+
81
+ ### Using Ticks
82
+
83
+ Slider ticks are small markers along the slider rail that mark a significant value. Ticks are purely visual, and do not alter user interaction. You can add slider ticks by passing an array of numbers within the slider's value range into the `ticks` property:
84
+
85
+ ```svelte example hideScript
86
+ <script>
87
+ import { Slider } from "fluent-svelte";
88
+ </script>
89
+
90
+ <Slider ticks={[0, 50, 100]} />
91
+ ```
92
+
93
+ You can also customize the appearance of the slider's ticks. The `tickPlacement` property will control how the ticks are displayed on the slider rail. The default value is `around`, which shows the ticks at both sides of the rail vertically. Tick placement can be either `around`, `before`, or `after`.
94
+
95
+ ### Tooltips
96
+
97
+ All sliders are accompanied by a tooltip that displays the current value of the slider. If you do not wish to display a tooltip, you can set the `tooltip` property to `false`.
98
+
99
+ ```svelte hideScript
100
+ <Slider tooltip={false} />
101
+ ```
102
+
103
+ Tooltip text can also be customized through the `prefix` and `suffix` properties, which will add a string respectively before or after the tooltip's text. This is useful if you want to convey units of measurement or other information about the slider's value.
104
+
105
+ ```svelte example hideScript
106
+ <script>
107
+ import { Slider } from "fluent-svelte";
108
+ </script>
109
+
110
+ <Slider prefix="$" />
111
+ <Slider suffix=" meters" />
112
+ ```
113
+
114
+ If you require further tooltip configuration, the tooltip's content can also be entirely overrided with your own using the `tooltip` slot.
115
+
116
+ The `tooltip` slot has three slot props: `value`, `prefix` and `suffix` which grant you access to the current value and the prefix/suffix strings respectively.
117
+
118
+ ```svelte example hideScript
119
+ <script>
120
+ import { Slider } from "fluent-svelte";
121
+ </script>
122
+
123
+ <Slider>
124
+ <svelte:fragment slot="tooltip" let:value let:prefix let:suffix>
125
+ {prefix}{value}{suffix}
126
+ <marquee>Custom HTML content!</marquee>
127
+ </svelte:fragment>
128
+ </Slider>
129
+ ```
130
+
131
+ ### Direction and Orientation
132
+
133
+ Sliders can be displayed in either a horizontal (left and right) or vertical orientation (up and down). By default, sliders are displayed in a horizontal orientation. You can change this by setting the `orientation` property to `vertical`.
134
+
135
+ ```svelte example hideScript
136
+ <script>
137
+ import { Slider } from "fluent-svelte";
138
+ </script>
139
+
140
+ <div style="block-size: 120px;">
141
+ <Slider orientation="vertical" />
142
+ </div>
143
+ ```
144
+
145
+ Slider tracks can also be reversed using the `reverse` property. This will change the direction of the slider's track. For example, if the slider is horizontal and the `reverse` property is set to `true`, the track will be displayed from right to left.
146
+
147
+ ```svelte example hideScript
148
+ <script>
149
+ import { Slider } from "fluent-svelte";
150
+ </script>
151
+
152
+ <Slider reverse />
153
+ ```
154
+
155
+ ### Trackless Sliders
156
+
157
+ A slider's fill indication can be removed by setting the `track` property to `false`. This will only hide the _track_, not the rail or thumb.
158
+
159
+ ### Disabled Sliders
160
+
161
+ If the slider is not meant to be clicked, you can use the `disabled` property to visually indicate this. If a slider is disabled, it will be unclickable.
162
+
163
+ ## Component API
164
+
165
+ <APIDocs {data} />
@@ -0,0 +1,46 @@
1
+ <script lang="ts">
2
+ import { TextBlock } from "$lib";
3
+ import { Showcase, APIDocs } from "$site/lib";
4
+
5
+ import data from "$lib/TextBlock/TextBlock.svelte?sveld&raw";
6
+ </script>
7
+
8
+ The TextBlock control renders a block of text in a given style depending on it's indended purpose in the layout. As the visual representation of language, TextBlock’s main task is to communicate information. Its style should never get in the way of that goal.
9
+
10
+ ```ts
11
+ import { TextBlock } from "fluent-svelte";
12
+ ```
13
+
14
+ <Showcase repl="9354fe2253804088b23e4dc9a882fa24" columns={3}>
15
+ <TextBlock variant="caption">Caption</TextBlock>
16
+ <TextBlock variant="body">Body</TextBlock>
17
+ <TextBlock variant="bodyStrong">Body Strong</TextBlock>
18
+ <TextBlock variant="bodyLarge">Body Large</TextBlock>
19
+ <TextBlock variant="subtitle">Subtitle</TextBlock>
20
+ <TextBlock variant="title">Title</TextBlock>
21
+ <TextBlock variant="titleLarge">Title Large</TextBlock>
22
+ <TextBlock variant="display">Display</TextBlock>
23
+ </Showcase>
24
+
25
+ ## Usage
26
+
27
+ TextBlocks only render a single given element, depending on which style is specified.
28
+
29
+ ### Styles
30
+
31
+ TextBlocks can be customized to a given purpose by passing in a `variant` property. The default variant is `body`.
32
+
33
+ | Variant | HTML Tag | Weight | Primary Font Family | Size / Line Height | Preview |
34
+ | ------------ | -------- | ------ | ------------------------- | ------------------ | ------------------------------------------------ |
35
+ | `caption` | `<span>` | `400` | Segoe UI Variable Small | 12/16px | <TextBlock variant="caption">Text</TextBlock> |
36
+ | `body` | `<span>` | `400` | Segoe UI Variable Text | 14/20px | <TextBlock variant="body">Text</TextBlock> |
37
+ | `bodyStrong` | `<h6>` | `600` | Segoe UI Variable Text | 14/20px | <TextBlock variant="bodyStrong">Text</TextBlock> |
38
+ | `bodyLarge` | `<h5>` | `600` | Segoe UI Variable Text | 18/24px | <TextBlock variant="bodyLarge">Text</TextBlock> |
39
+ | `subtitle` | `<h4>` | `600` | Segoe UI Variable Display | 20/28px | <TextBlock variant="subtitle">Text</TextBlock> |
40
+ | `title` | `<h3>` | `600` | Segoe UI Variable Display | 28/36px | <TextBlock variant="title">Text</TextBlock> |
41
+ | `titleLarge` | `<h2>` | `600` | Segoe UI Variable Display | 40/52px | <TextBlock variant="titleLarge">Text</TextBlock> |
42
+ | `display` | `<h1>` | `600` | Segoe UI Variable Display | 68/92px | <TextBlock variant="display">Text</TextBlock> |
43
+
44
+ ## Component API
45
+
46
+ <APIDocs {data} />
@@ -0,0 +1,124 @@
1
+ <script lang="ts">
2
+ import { TextBox, InfoBar } from "$lib";
3
+ import { Showcase, APIDocs } from "$site/lib";
4
+
5
+ import data from "$lib/TextBox/TextBox.svelte?sveld&raw";
6
+ </script>
7
+
8
+ The TextBox control lets a user type text into an app. The text displays on the screen in a simple, plaintext format on a single line. It additionally comes with a set of buttons which allow users to perform specialized actions on the text, such as showing a password or clearing the TextBox's contents.
9
+
10
+ ```ts
11
+ import { TextBox } from "fluent-svelte";
12
+ ```
13
+
14
+ <Showcase columns={2} repl="65b817e67ff3450da0c5755b5fdac9f7">
15
+ <TextBox placeholder="TextBox" />
16
+ <TextBox placeholder="TextBox" disabled />
17
+ <TextBox type="search" placeholder="TextBox" />
18
+ <TextBox type="search" placeholder="TextBox" disabled />
19
+ <TextBox type="password" placeholder="TextBox" />
20
+ <TextBox type="password" placeholder="TextBox" disabled />
21
+ </Showcase>
22
+
23
+ ## Usage
24
+
25
+ TextBox is an extension of [HTML's native `<input />` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). Most props/attributes that aren't explicitly documented here should still work the same.
26
+
27
+ ### Controlling Value
28
+
29
+ A TextBox's current text content can be set with the `value` property.
30
+
31
+ ```svelte hideScript
32
+ <TextBox value="Default value" />
33
+ ```
34
+
35
+ Additionally, you can use svelte's two-way binding syntax to bind the value to a variable.
36
+
37
+ ```svelte example
38
+ <script>
39
+ import { TextBox } from "fluent-svelte";
40
+
41
+ let value = "Default value";
42
+ </script>
43
+
44
+ <TextBox bind:value />
45
+
46
+ Current value: {value}
47
+ ```
48
+
49
+ ### TextBox Types
50
+
51
+ You can customize the intended input type of the TextBox by setting the `type` property. Most HTML [`<input>` type attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types) that accept text input are supported.
52
+
53
+ Supported types: `text`, `number`, `search`, `password`, `email`, `tel`, `url`, `date`, `datetime-local`, `month`, `time`, `week`.
54
+
55
+ <InfoBar severity="caution" title="NumberBox vs. the {`"number"`} type">
56
+ While you <i>can</i> use the <code>number</code> type with TextBox, it's probably a better idea to use the specialized <a href="numberbox">NumberBox</a> component instead, which is an extension of TextBox designed for handling numeric inputs.
57
+ </InfoBar>
58
+
59
+ Most of these types will simply set the `type` attribute of the TextBox's input element. Some of these types, however, have additional functionality added specific to their input method.
60
+
61
+ - On `search` types - A search button will be added to the end of the TextBox to allow users to submit a search query. You can use the `on:search` event to handle the search query. If you wish to hide the search button when using this type, you can set the `searchButton` property to `false`.
62
+ - On `password` types - A password reveal button will be added to the end of the TextBox to allow users to reveal the input's value. You can use the `on:reveal` event to run code when the password is revealed. If you wish to hide the reveal button when using this type, you can set the `revealButton` property to `false`.
63
+
64
+ ### Placeholders
65
+
66
+ TextBox supports a `placeholder` property that will be displayed as text in lower emphasis when it's value is empty. These can be used to describe the purpose or type of value the TextBox is meant to accept.
67
+
68
+ ```svelte example hideScript
69
+ <script>
70
+ import { TextBox } from "fluent-svelte";
71
+ </script>
72
+
73
+ <TextBox placeholder="Send a message" />
74
+ ```
75
+
76
+ ### Buttons
77
+
78
+ TextBox supports a set of buttons that are added to the end of it's container. These buttons can be used to perform actions on the TextBox's value. [Depending on the `type` of the TextBox, these buttons may vary with different functionality and behavior](#textbox-types).
79
+
80
+ Most TextBox types will feature a clear button. This button will clear the TextBox's value, then focus the input when clicked. If you wish to hide this button, you can set the `clearButton` property to `false`. If you wish to run any code after the clear button is used, you can also handle the `on:clear` event.
81
+
82
+ Along with the builtin action buttons, you can also add your own buttons to the end of the TextBox using the `TextBoxButton` component and the TextBox's `buttons` slot:
83
+
84
+ ```svelte example hideScript
85
+ <script>
86
+ import { TextBox, TextBoxButton } from "fluent-svelte";
87
+ </script>
88
+
89
+ <TextBox placeholder="Custom buttons!">
90
+ <TextBoxButton slot="buttons" on:click={() => alert("Clicked!")}>
91
+ <!-- https://github.com/microsoft/fluentui-system-icons -->
92
+ <svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
93
+ <path
94
+ d="M7.85355 0.146447C7.65829 -0.0488155 7.34171 -0.0488155 7.14645 0.146447C6.95118 0.341709 6.95118 0.658291 7.14645 0.853553L8.29603 2.00314C4.80056 2.11088 2 4.97839 2 8.5C2 12.0899 4.91015 15 8.5 15C12.0899 15 15 12.0899 15 8.5C15 8.48656 15 8.47313 14.9999 8.45971C14.9983 8.2001 14.7805 8 14.5209 8H14.4782C14.2093 8 14 8.23107 14 8.5C14 11.5376 11.5376 14 8.5 14C5.46243 14 3 11.5376 3 8.5C3 5.53311 5.34917 3.11491 8.28892 3.00398L7.14645 4.14645C6.95118 4.34171 6.95118 4.65829 7.14645 4.85355C7.34171 5.04882 7.65829 5.04882 7.85355 4.85355L9.85355 2.85355C10.0488 2.65829 10.0488 2.34171 9.85355 2.14645L7.85355 0.146447ZM11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355L8.85355 9.85355C8.65829 10.0488 8.34171 10.0488 8.14645 9.85355L6.64645 8.35355C6.45118 8.15829 6.45118 7.84171 6.64645 7.64645C6.84171 7.45118 7.15829 7.45118 7.35355 7.64645L8.5 8.79289L11.1464 6.14645C11.3417 5.95118 11.6583 5.95118 11.8536 6.14645Z"
95
+ fill="currentColor"
96
+ />
97
+ </svg>
98
+ </TextBoxButton>
99
+ </TextBox>
100
+ ```
101
+
102
+ ### Disabled and Readonly States
103
+
104
+ There are two methods to (completely) restrict manual input on a TextBox: the `disabled` and `readonly` properties.
105
+
106
+ - The `disabled` property will prevent the user from entering text into the TextBox as well as style the TextBox to indicate this. The TextBox will not be focusable and will not respond to keyboard events.
107
+ - The `readonly` property will only prevent the user from entering text into the TextBox. The TextBox will still be focusable, however, and no changes to the styling will be made.
108
+
109
+ <InfoBar severity="attention" title="Buttons and these properties">
110
+ It should be noted that while using either of these modes that the clear button will not be displayed, in order to prevent users from modifying the TextBox's content. The <code>clearButton</code> property will have no effect on this behavior. Additionally, when the TextBox is <code>disabled</code>, the search and password reveal buttons will not be rendered into their respective types either.
111
+ </InfoBar>
112
+
113
+ ```svelte example hideScript
114
+ <script>
115
+ import { TextBox } from "fluent-svelte";
116
+ </script>
117
+
118
+ <TextBox placeholder="disabled TextBox" disabled />
119
+ <TextBox placeholder="readonly TextBox" readonly />
120
+ ```
121
+
122
+ ## Component API
123
+
124
+ <APIDocs {data} />
@@ -0,0 +1,73 @@
1
+ <script lang="ts">
2
+ import { ToggleSwitch, Button, InfoBar } from "$lib";
3
+ import { Showcase, APIDocs } from "$site/lib";
4
+
5
+ import data from "$lib/ToggleSwitch/ToggleSwitch.svelte?sveld&raw";
6
+ </script>
7
+
8
+ The toggle switch represents a physical switch that allows users to turn things on or off, like a light switch. Use toggle switch controls to present users with two mutually exclusive options (such as on/off), where choosing an option provides immediate results.
9
+
10
+ ```ts
11
+ import { ToggleSwitch } from "fluent-svelte";
12
+ ```
13
+
14
+ <Showcase columns={2} repl="4b7217ee24294302937ec6c69db1bbc0">
15
+ <ToggleSwitch>ToggleSwitch</ToggleSwitch>
16
+ <ToggleSwitch checked>ToggleSwitch</ToggleSwitch>
17
+ <ToggleSwitch disabled>ToggleSwitch</ToggleSwitch>
18
+ <ToggleSwitch checked disabled>ToggleSwitch</ToggleSwitch>
19
+ </Showcase>
20
+
21
+ ## Usage
22
+
23
+ `<ToggleSwitch />` is a wrapper around HTML's `<input />` checkbox type. As such, the APIs share some similarities.
24
+
25
+ ### Checking and Unchecking
26
+
27
+ You can programmatically control if the ToggleSwitch is in it's checked state by setting the `checked` property.
28
+
29
+ ```svelte example hideScript
30
+ <script>
31
+ import { ToggleSwitch } from "fluent-svelte";
32
+ </script>
33
+
34
+ <ToggleSwitch checked />
35
+ ```
36
+
37
+ Additionally, you can use svelte's two-way binding syntax to bind the checked state to a variable.
38
+
39
+ ```svelte example
40
+ <script>
41
+ import { ToggleSwitch } from "fluent-svelte";
42
+
43
+ let checked = false;
44
+ </script>
45
+
46
+ <ToggleSwitch bind:checked />
47
+
48
+ Current state: {checked ? "checked" : "unchecked"}
49
+ ```
50
+
51
+ ### Labels
52
+
53
+ Passing in content to the ToggleSwitch's slot will cause that content to be rendered into a label for the control.
54
+
55
+ ```svelte example hideScript
56
+ <script>
57
+ import { ToggleSwitch } from "fluent-svelte";
58
+ </script>
59
+
60
+ <ToggleSwitch>I have a label!</ToggleSwitch>
61
+ ```
62
+
63
+ ### Value
64
+
65
+ For usage in forms, you can set a `value` property which will set the [value](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value) of the ToggleSwitch's `<input>` element.
66
+
67
+ ### Disabled ToggleSwitches
68
+
69
+ If the ToggleSwitch is not meant to be clicked, you can use the `disabled` property to visually indicate this. If a ToggleSwitch is disabled, it will be unclickable.
70
+
71
+ ## Component API
72
+
73
+ <APIDocs {data} />
@@ -0,0 +1,116 @@
1
+ <script lang="ts">
2
+ import { InfoBar, Button } from "$lib";
3
+ import { CopyBox } from "$site/lib";
4
+ </script>
5
+
6
+ This page will guide you through the process of adding fluent-svelte to your existing Svelte project. If you don't have a Svelte or SvelteKit project already, you can create one using [this guide](https://svelte.dev/blog/the-easiest-way-to-get-started).
7
+
8
+ <InfoBar severity="attention" title="Before We Start" message="This tutorial assumes you have basic knowledge of Svelte.">
9
+ <Button slot="action" variant="accent">
10
+ Learn Svelte
11
+ </Button>
12
+ </InfoBar>
13
+
14
+ ### Step 1: Install the Library
15
+
16
+ This will install fluent-svelte and it's required dependencies. This can be done using a package manager of your choice.
17
+
18
+ <label>
19
+ npm
20
+ <CopyBox value="npm i --save-dev fluent-svelte" />
21
+ </label>
22
+
23
+ <label>
24
+ pnpm
25
+ <CopyBox value="pnpm i --save-dev fluent-svelte" />
26
+ </label>
27
+
28
+ <label>
29
+ yarn
30
+ <CopyBox value="yarn add --dev fluent-svelte" />
31
+ </label>
32
+
33
+ ### Step 2: Add Theme File
34
+
35
+ Fluent Svelte components use a set of common resources to style their elements. These values are defined in a theme file that must be imported into your project before components can render properly.
36
+
37
+ `src/App.svelte` (or `src/routes/__layout.svelte` if using SvelteKit)
38
+
39
+ ```svelte
40
+ <script>
41
+ import "fluent-svelte/theme.css";
42
+ </script>
43
+ ```
44
+
45
+ <InfoBar title="Bundler Support" severity="caution">
46
+ In some cases, your bundler may not have the capability to resolve CSS files. Both the default Svelte template and the SvelteKit starter project (Vite) have this ability, however you might need to install a <a href="https://gist.github.com/Tropix126/6306afeffbcc551425d5658b856e8c4c" target="_blank" rel="noreferrer noopener">dedicated bundler plugin</a> to import CSS.
47
+ </InfoBar>
48
+
49
+ Alternatively, you can import the theme file from a CDN (though this generally isn't recommended).
50
+
51
+ ```svelte
52
+ <style>
53
+ @import url("https://unpkg.com/fluent-svelte/theme.css");
54
+ /* ...or @import url("https://cdn.jsdelivr.net/npm/fluent-svelte/theme.css"); */
55
+ </style>
56
+ ```
57
+
58
+ ### Step 3: Importing a Component
59
+
60
+ Components are exported from a single index file in the library. They can be imported and used in your project like so:
61
+
62
+ ```svelte example
63
+ <script>
64
+ import { Button, Checkbox } from "fluent-svelte";
65
+ </script>
66
+
67
+ <Button>Click me!</Button>
68
+ <Checkbox>Check me!</Checkbox>
69
+ ```
70
+
71
+ Alternatively you can import under a namespace:
72
+
73
+ ```svelte
74
+ <script>
75
+ import * as Fluent from "fluent-svelte";
76
+ </script>
77
+
78
+ <Fluent.Button>Click me!</Fluent.Button>
79
+ <Fluent.Checkbox>Check me!</Fluent.Checkbox>
80
+ ```
81
+
82
+ ### Svelte REPL Usage
83
+
84
+ `fluent-svelte` components can also be imported into the [Svelte REPL](https://svelte.dev/repl/).
85
+
86
+ In the REPL, packages are automatically installed by name when using an `import` statement, so the installation step can be skipped. Because the REPL doesn't support importing CSS in `node_modules`, we'll need to import the theme file through a CDN.
87
+
88
+ ```svelte
89
+ <script>
90
+ import { Button, Checkbox } from "fluent-svelte";
91
+ </script>
92
+
93
+ <button>Click me!</button>
94
+
95
+ <style>
96
+ @import url("https://unpkg.com/fluent-svelte/theme.css");
97
+
98
+ /* Some base styles to get things looking right. */
99
+ :global(body) {
100
+ background-color: var(--fds-solid-background-base);
101
+ color: var(--fds-text-primary);
102
+ }
103
+ </style>
104
+ ```
105
+
106
+ <Button variant="hyperlink" href="https://svelte.dev/repl/2a30b6d202d24fb6b14783132b86b706" target="_blank" rel="noreferrer noopener">View this in the REPL</Button>
107
+
108
+ <style>
109
+ h3 {
110
+ margin-block-start: 72px !important;
111
+ }
112
+
113
+ label {
114
+ font-weight: 600;
115
+ }
116
+ </style>
@@ -0,0 +1,37 @@
1
+ <script>
2
+ import { InfoBar } from "$lib";
3
+ </script>
4
+
5
+ Welcome to the Fluent Svelte documentation! This page will explain the basic concepts and usage of the library.
6
+
7
+ ### What is this?
8
+
9
+ `fluent-svelte` is a [Svelte](http://svelte.dev/) component UI library that emulates the look and feel of [Microsoft's Windows UI Controls](https://github.com/microsoft/microsoft-ui-xaml/) which conform to the Fluent Design System.
10
+
11
+ <InfoBar
12
+ severity="caution"
13
+ title="Before We Begin"
14
+ message="This is not a 1-to-1 re-implementation of WinUI, but rather a faithful attempt to emulate the look and feel of WinUI on the web. Some controls will have API or behaviorial differences, but the overall look and feel should be very similar."
15
+ />
16
+
17
+ ### Features
18
+
19
+ - [SvelteKit](https://kit.svelte.dev/) and SSR Compatible
20
+ - [TypeScript](https://typescriptlang.org/) and type definitions are supported, but optional.
21
+ - Full RTL support with no additional configuration.
22
+ - All components are accessible according to [WAI-ARIA](https://www.w3.org/WAI/standards-guidelines/aria/) standards.
23
+ - Theming support using CSS custom properties.
24
+ - Minimal third-party dependency usage.
25
+ - Reduced motion support.
26
+ - Easy setup. Just install the library, add some base styles, and you're ready to go.
27
+ - Minimal CSS overhead. Styles are included and scoped alongside their respective components, only bundling the CSS you need.
28
+
29
+ ### Undocumented Components
30
+
31
+ This documentation site is still not entirely finished. Many components exported in the library are not yet documented. That progress can be tracked [here](https://github.com/Tropix126/fluent-svelte/issues/13). For now, i've setup a testing page with every component included in the library that is viewable [here](https://fluent-svelte.vercel.app/test). It's source can be viewed [here](https://github.com/Tropix126/fluent-svelte/blob/main/src/routes/test/index.svelte).
32
+
33
+ Please keep in mind that any undocumented component is _considered to be in the 0.x phase of development_. This means that they could potentially recieve breaking API changes or be heavily updated before being finalized.
34
+
35
+ ### Changelog
36
+
37
+ See [CHANGELOG.md](https://github.com/Tropix126/fluent-svelte/blob/main/CHANGELOG.md).
File without changes