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.
- package/.prettierignore +1 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/package.json +83 -0
- package/src/app.html +12 -0
- package/src/global.d.ts +1 -0
- package/src/lib/AutoSuggestBox/AutoSuggestBox.scss +44 -0
- package/src/lib/AutoSuggestBox/AutoSuggestBox.svelte +173 -0
- package/src/lib/Button/Button.scss +94 -0
- package/src/lib/Button/Button.svelte +48 -0
- package/src/lib/CalendarDatePicker/CalendarDatePicker.scss +15 -0
- package/src/lib/CalendarDatePicker/CalendarDatePicker.svelte +86 -0
- package/src/lib/CalendarView/CalendarView.scss +156 -0
- package/src/lib/CalendarView/CalendarView.svelte +753 -0
- package/src/lib/CalendarView/CalendarViewItem.scss +130 -0
- package/src/lib/CalendarView/CalendarViewItem.svelte +33 -0
- package/src/lib/Checkbox/Checkbox.scss +117 -0
- package/src/lib/Checkbox/Checkbox.svelte +81 -0
- package/src/lib/ComboBox/ComboBox.scss +152 -0
- package/src/lib/ComboBox/ComboBox.svelte +360 -0
- package/src/lib/ComboBox/ComboBoxItem.scss +80 -0
- package/src/lib/ComboBox/ComboBoxItem.svelte +30 -0
- package/src/lib/ContentDialog/ContentDialog.scss +68 -0
- package/src/lib/ContentDialog/ContentDialog.svelte +123 -0
- package/src/lib/ContextMenu/ContextMenu.scss +11 -0
- package/src/lib/ContextMenu/ContextMenu.svelte +104 -0
- package/src/lib/Expander/Expander.scss +134 -0
- package/src/lib/Expander/Expander.svelte +123 -0
- package/src/lib/Flipper/Flipper.svelte +49 -0
- package/src/lib/Flyout/FlyoutSurface.scss +14 -0
- package/src/lib/Flyout/FlyoutSurface.svelte +21 -0
- package/src/lib/Flyout/FlyoutWrapper.scss +81 -0
- package/src/lib/Flyout/FlyoutWrapper.svelte +126 -0
- package/src/lib/IconButton/IconButton.scss +31 -0
- package/src/lib/IconButton/IconButton.svelte +49 -0
- package/src/lib/InfoBadge/InfoBadge.scss +39 -0
- package/src/lib/InfoBadge/InfoBadge.svelte +81 -0
- package/src/lib/InfoBar/InfoBar.scss +122 -0
- package/src/lib/InfoBar/InfoBar.svelte +133 -0
- package/src/lib/ListItem/ListItem.scss +74 -0
- package/src/lib/ListItem/ListItem.svelte +88 -0
- package/src/lib/MenuBar/MenuBar.scss +10 -0
- package/src/lib/MenuBar/MenuBar.svelte +49 -0
- package/src/lib/MenuBar/MenuBarItem.scss +38 -0
- package/src/lib/MenuBar/MenuBarItem.svelte +135 -0
- package/src/lib/MenuBar/flyoutState.ts +5 -0
- package/src/lib/MenuFlyout/MenuFlyoutDivider.scss +7 -0
- package/src/lib/MenuFlyout/MenuFlyoutDivider.svelte +14 -0
- package/src/lib/MenuFlyout/MenuFlyoutItem.scss +147 -0
- package/src/lib/MenuFlyout/MenuFlyoutItem.svelte +239 -0
- package/src/lib/MenuFlyout/MenuFlyoutSurface.scss +42 -0
- package/src/lib/MenuFlyout/MenuFlyoutSurface.svelte +28 -0
- package/src/lib/MenuFlyout/MenuFlyoutWrapper.scss +64 -0
- package/src/lib/MenuFlyout/MenuFlyoutWrapper.svelte +114 -0
- package/src/lib/NavigationView/NavigationView.scss +0 -0
- package/src/lib/NavigationView/NavigationView.svelte +82 -0
- package/src/lib/NumberBox/NumberBox.scss +31 -0
- package/src/lib/NumberBox/NumberBox.svelte +267 -0
- package/src/lib/PersonPicture/PersonPicture.scss +35 -0
- package/src/lib/PersonPicture/PersonPicture.svelte +62 -0
- package/src/lib/ProgressBar/ProgressBar.scss +83 -0
- package/src/lib/ProgressBar/ProgressBar.svelte +60 -0
- package/src/lib/ProgressRing/ProgressRing.scss +37 -0
- package/src/lib/ProgressRing/ProgressRing.svelte +73 -0
- package/src/lib/RadioButton/RadioButton.scss +114 -0
- package/src/lib/RadioButton/RadioButton.svelte +67 -0
- package/src/lib/RangeSlider/RangeSlider.svelte +91 -0
- package/src/lib/ScrollView/ScrollView.svelte +9 -0
- package/src/lib/Slider/Slider.scss +263 -0
- package/src/lib/Slider/Slider.svelte +261 -0
- package/src/lib/TextBlock/TextBlock.scss +62 -0
- package/src/lib/TextBlock/TextBlock.svelte +70 -0
- package/src/lib/TextBox/TextBox.scss +108 -0
- package/src/lib/TextBox/TextBox.svelte +225 -0
- package/src/lib/TextBox/TextBoxButton.scss +34 -0
- package/src/lib/TextBox/TextBoxButton.svelte +27 -0
- package/src/lib/ToggleSwitch/ToggleSwitch.scss +118 -0
- package/src/lib/ToggleSwitch/ToggleSwitch.svelte +55 -0
- package/src/lib/Tooltip/TooltipSurface.scss +16 -0
- package/src/lib/Tooltip/TooltipSurface.svelte +27 -0
- package/src/lib/Tooltip/TooltipWrapper.scss +66 -0
- package/src/lib/Tooltip/TooltipWrapper.svelte +117 -0
- package/src/lib/_mixins.scss +130 -0
- package/src/lib/index.ts +33 -0
- package/src/lib/internal.ts +213 -0
- package/src/lib/svelte-jsx.d.ts +14 -0
- package/src/lib/theme.css +414 -0
- package/src/routes/__layout.svelte +48 -0
- package/src/routes/docs/__layout.svelte +122 -0
- package/src/routes/docs/components/button.md +43 -0
- package/src/routes/docs/components/calendarview.md +188 -0
- package/src/routes/docs/components/checkbox.md +87 -0
- package/src/routes/docs/components/contentdialog.md +155 -0
- package/src/routes/docs/components/expander.md +115 -0
- package/src/routes/docs/components/flyout.md +107 -0
- package/src/routes/docs/components/iconbutton.md +39 -0
- package/src/routes/docs/components/infobadge.md +54 -0
- package/src/routes/docs/components/infobar.md +102 -0
- package/src/routes/docs/components/listitem.md +87 -0
- package/src/routes/docs/components/personpicture.md +125 -0
- package/src/routes/docs/components/progressring.md +83 -0
- package/src/routes/docs/components/radiobutton.md +88 -0
- package/src/routes/docs/components/slider.md +165 -0
- package/src/routes/docs/components/textblock.md +46 -0
- package/src/routes/docs/components/textbox.md +124 -0
- package/src/routes/docs/components/toggleswitch.md +73 -0
- package/src/routes/docs/getting-started.md +116 -0
- package/src/routes/docs/index.md +37 -0
- package/src/routes/docs/internals/index.md +0 -0
- package/src/routes/index.svelte +121 -0
- package/src/routes/test/__layout-test.svelte +1 -0
- package/src/routes/test/index.svelte +757 -0
- package/src/routes/test/nav.svelte +7 -0
- package/src/site/data/docs.ts +176 -0
- package/src/site/data/home.ts +12 -0
- package/src/site/lib/APIDocs/APIDocs.svelte +178 -0
- package/src/site/lib/APIDocs/ParsedComponent.d.ts +85 -0
- package/src/site/lib/CopyBox/CopyBox.svelte +23 -0
- package/src/site/lib/Example/Example.scss +33 -0
- package/src/site/lib/Example/Example.svelte +18 -0
- package/src/site/lib/HeroCard/HeroCard.scss +24 -0
- package/src/site/lib/HeroCard/HeroCard.svelte +36 -0
- package/src/site/lib/Metadata/Metadata.svelte +14 -0
- package/src/site/lib/Navbar/Navbar.scss +92 -0
- package/src/site/lib/Navbar/Navbar.svelte +47 -0
- package/src/site/lib/PageSection/PageSection.scss +57 -0
- package/src/site/lib/PageSection/PageSection.svelte +10 -0
- package/src/site/lib/Showcase/Showcase.scss +53 -0
- package/src/site/lib/Showcase/Showcase.svelte +67 -0
- package/src/site/lib/Toc/Toc.scss +18 -0
- package/src/site/lib/Toc/Toc.svelte +59 -0
- package/src/site/lib/TreeView/TreeView.svelte +89 -0
- package/src/site/lib/index.ts +9 -0
- package/src/site/styles/_markdown.scss +260 -0
- package/src/site/styles/_mixins.scss +319 -0
- package/src/site/styles/global.scss +40 -0
- package/src/site/styles/pages/docs.scss +74 -0
- package/src/site/styles/pages/home.scss +134 -0
- package/static/bloom-mica-dark.png +0 -0
- package/static/bloom-mica-light.png +0 -0
- package/static/logo.svg +11 -0
- package/svelte.config.js +57 -0
- package/tsconfig.json +38 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { IconButton } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import Circle from "@fluentui/svg-icons/icons/circle_16_regular.svg?raw";
|
|
6
|
+
|
|
7
|
+
import data from "$lib/IconButton/IconButton.svelte?raw&sveld";
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
An Icon Button is a clickable control that triggers an immediate action. Unlike the [Button](button) control, it serves the purpose of encapsulating an icon glyph as it's content.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { IconButton } from "fluent-svelte";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
<Showcase columns={2} repl="89b152e7c33047768b6c242eb2a6afcb">
|
|
17
|
+
<IconButton>
|
|
18
|
+
{@html Circle}
|
|
19
|
+
</IconButton>
|
|
20
|
+
<IconButton disabled>
|
|
21
|
+
{@html Circle}
|
|
22
|
+
</IconButton>
|
|
23
|
+
</Showcase>
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
While IconButton is not a direct extension of [Button](button), it shares many similarities with it's API.
|
|
28
|
+
|
|
29
|
+
### Links
|
|
30
|
+
|
|
31
|
+
An IconButton can either be a clickable action or a link. By default, an IconButton will be rendered as a standard HTML `<button>` element. If an `href` property is provided, the IconButton will be converted into an `<a>` tag.
|
|
32
|
+
|
|
33
|
+
### Disabled Buttons
|
|
34
|
+
|
|
35
|
+
If the button is not meant to be clicked, you can use the `disabled` property to visually indicate this. If a button is disabled, it will be unclickable and the `href` property will be ignored.
|
|
36
|
+
|
|
37
|
+
## Component API
|
|
38
|
+
|
|
39
|
+
<APIDocs {data} />
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { InfoBadge, Button } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/InfoBadge/InfoBadge.svelte?raw&sveld";
|
|
6
|
+
|
|
7
|
+
const severities = ["information", "attention", "success", "caution", "critical"];
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { InfoBadge } from "fluent-svelte";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
<Showcase repl="ce7c58c352e24e84ad6838663e6dcd4e" columns={5}>
|
|
17
|
+
{#each severities as severity}
|
|
18
|
+
<InfoBadge {severity} />
|
|
19
|
+
{/each}
|
|
20
|
+
{#each severities as severity}
|
|
21
|
+
<InfoBadge {severity}>{Math.floor(Math.random() * 10)}</InfoBadge>
|
|
22
|
+
{/each}
|
|
23
|
+
</Showcase>
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Severity
|
|
28
|
+
|
|
29
|
+
InfoBadges can take in a `severity` prop, which represent the type of information you wish to convey to the user. The default severity is `attention`.
|
|
30
|
+
|
|
31
|
+
| Severity | Preview |
|
|
32
|
+
| ------------- | ------------------------------------ |
|
|
33
|
+
| `attention` | <InfoBadge severity="attention" /> |
|
|
34
|
+
| `information` | <InfoBadge severity="information" /> |
|
|
35
|
+
| `success` | <InfoBadge severity="success" /> |
|
|
36
|
+
| `caution` | <InfoBadge severity="caution" /> |
|
|
37
|
+
| `critical` | <InfoBadge severity="critical" /> |
|
|
38
|
+
|
|
39
|
+
### Custom Content
|
|
40
|
+
|
|
41
|
+
The default badge glyph can be overrided with your own content. This can be useful if you wish display text, or an alert count. Passing HTML content into the default slot will override the glyph with said content.
|
|
42
|
+
|
|
43
|
+
```svelte example hideScript
|
|
44
|
+
<script>
|
|
45
|
+
import { InfoBadge } from "fluent-svelte";
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<InfoBadge>99</InfoBadge>
|
|
49
|
+
<InfoBadge severity="critical">bazinga</InfoBadge>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Component API
|
|
53
|
+
|
|
54
|
+
<APIDocs {data} />
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { InfoBar, InfoBadge, Button } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/InfoBar/InfoBar.svelte?raw&sveld";
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { InfoBar } from "fluent-svelte";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
<Showcase repl="789be6a7b377455aab6f44e123885423" columns={2}>
|
|
15
|
+
<InfoBar title="Title" message="Message">
|
|
16
|
+
<Button slot="action">Action</Button>
|
|
17
|
+
</InfoBar>
|
|
18
|
+
<InfoBar title="Title" message="Message" severity="attention">
|
|
19
|
+
<Button slot="action" variant="accent">Action</Button>
|
|
20
|
+
</InfoBar>
|
|
21
|
+
<InfoBar title="Title" message="Message" closable={false} />
|
|
22
|
+
<InfoBar title="Title" message="Message" severity="success" />
|
|
23
|
+
<InfoBar title="Title" message="Message" severity="caution" />
|
|
24
|
+
<InfoBar title="Title" message="Message" severity="critical" />
|
|
25
|
+
</Showcase>
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Text Contents - `title` and `message`
|
|
30
|
+
|
|
31
|
+
There are two areas of text that can be customized - the title and the message. Both are optional, but at least one is recommended.
|
|
32
|
+
|
|
33
|
+
- You can specify a title for the InfoBar using `title` property.
|
|
34
|
+
- You can set the InfoBar's message using the `message` property.
|
|
35
|
+
|
|
36
|
+
```svelte example hideScript
|
|
37
|
+
<script>
|
|
38
|
+
import { InfoBar } from "fluent-svelte";
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<InfoBar title="Title" message="Message" />
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If you need to include HTML content into the message, you can also just use the default slot.
|
|
45
|
+
|
|
46
|
+
```svelte example hideScript
|
|
47
|
+
<script>
|
|
48
|
+
import { InfoBar } from "fluent-svelte";
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<InfoBar>
|
|
52
|
+
Visit <a href="https://fluent-svelte.vercel.app">Fluent Svelte</a> for some neat fluent design components!
|
|
53
|
+
</InfoBar>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Severity
|
|
57
|
+
|
|
58
|
+
InfoBars can take in a `severity` prop, which represent the type of information you wish to convey to the user. The default severity is `information`.
|
|
59
|
+
|
|
60
|
+
| Severity | Badge | Usage | Preview |
|
|
61
|
+
| ------------- | ------------------------------------ | ----------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
62
|
+
| `information` | <InfoBadge severity="information" /> | Non-critical messages containing general information. | <InfoBar severity="information" title="Information" /> |
|
|
63
|
+
| `attention` | <InfoBadge severity="attention" /> | Messages that are non-critical, but still important to the user. | <InfoBar severity="attention" title="Attention" /> |
|
|
64
|
+
| `success` | <InfoBadge severity="success" /> | Messages that convey an action that has postively been completed. | <InfoBar severity="success" title="Success" /> |
|
|
65
|
+
| `caution` | <InfoBadge severity="caution" /> | Messages that serve to warn the user of a potentially dangerous action. | <InfoBar severity="caution" title="Caution" /> |
|
|
66
|
+
| `critical` | <InfoBadge severity="critical" /> | Higher-severity messages that convey a dangerous or failed action. | <InfoBar severity="critical" title="Critical" /> |
|
|
67
|
+
|
|
68
|
+
### Action Buttons
|
|
69
|
+
|
|
70
|
+
An action button can be passed in using the `action` slot. It's recommended that you use the [Button](/docs/components/button) component for this, but any HTML element is valid.
|
|
71
|
+
|
|
72
|
+
```svelte example hideScript
|
|
73
|
+
<script>
|
|
74
|
+
import { InfoBar, Button } from "fluent-svelte";
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<InfoBar title="Title" message="Message">
|
|
78
|
+
<Button slot="action">Action</Button>
|
|
79
|
+
</InfoBar>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Controlling Visibility
|
|
83
|
+
|
|
84
|
+
InfoBars by default are `open`. This means that they are rendered into the DOM. When the close button is pressed, they will be removed from the DOM and the `open` property will be set back to `false`.
|
|
85
|
+
|
|
86
|
+
```svelte example
|
|
87
|
+
<script>
|
|
88
|
+
import { InfoBar, Button } from "fluent-svelte";
|
|
89
|
+
|
|
90
|
+
let open = false;
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<Button on:click={() => (open = !open)}>
|
|
94
|
+
{open ? "Close" : "Open"}
|
|
95
|
+
</Button>
|
|
96
|
+
|
|
97
|
+
<InfoBar title="Title" message="Message" bind:open />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Component API
|
|
101
|
+
|
|
102
|
+
<APIDocs {data} />
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ListItem } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import Circle from "@fluentui/svg-icons/icons/circle_16_regular.svg?raw";
|
|
6
|
+
|
|
7
|
+
import data from "$lib/ListItem/ListItem.svelte?raw&sveld";
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { ListItem } from "fluent-svelte";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
<Showcase repl="">
|
|
17
|
+
<div style="inline-size: 240px">
|
|
18
|
+
<ListItem>ListItem</ListItem>
|
|
19
|
+
<ListItem>
|
|
20
|
+
<svelte:fragment slot="icon">
|
|
21
|
+
{@html Circle}
|
|
22
|
+
</svelte:fragment>
|
|
23
|
+
ListItem
|
|
24
|
+
</ListItem>
|
|
25
|
+
<ListItem selected>ListItem</ListItem>
|
|
26
|
+
<ListItem disabled>ListItem</ListItem>
|
|
27
|
+
</div>
|
|
28
|
+
</Showcase>
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
A ListItem is either a general-purpose item or a link. By default, an item will be rendered as a standard HTML `<li>` element. If an `href` property is provided, the item will be converted into an `<a>` tag.
|
|
33
|
+
|
|
34
|
+
### Selecting Items
|
|
35
|
+
|
|
36
|
+
An item can be marked as _selected_ to indicate that it a currently active option. To do this, use the `selected` property.
|
|
37
|
+
|
|
38
|
+
```svelte example hideScript
|
|
39
|
+
<script>
|
|
40
|
+
import { ListItem } from "fluent-svelte";
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<ListItem selected>Text</ListItem>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also listen to the `select` event, which is dispatched when the `selected` property is changed to a truthy value.
|
|
47
|
+
|
|
48
|
+
### Disabled Items
|
|
49
|
+
|
|
50
|
+
If the item is not meant to be clicked, you can use the `disabled` property to visually indicate this. If an item is disabled, it will be unclickable and the `href` prop will be ignored.
|
|
51
|
+
|
|
52
|
+
```svelte example hideScript
|
|
53
|
+
<script>
|
|
54
|
+
import { ListItem } from "fluent-svelte";
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<ListItem disabled>Text</ListItem>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Adding an Icon
|
|
61
|
+
|
|
62
|
+
You can easily add an icon to an item using the `icon` slot. Passing in an SVG element will render it before any contents with 16x16 dimensions.
|
|
63
|
+
|
|
64
|
+
```svelte example hideScript
|
|
65
|
+
<script>
|
|
66
|
+
import { ListItem } from "fluent-svelte";
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<ListItem>
|
|
70
|
+
<!-- https://github.com/microsoft/fluentui-system-icons -->
|
|
71
|
+
<svg slot="icon" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
|
72
|
+
<path
|
|
73
|
+
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"
|
|
74
|
+
fill="currentColor"
|
|
75
|
+
/>
|
|
76
|
+
</svg>
|
|
77
|
+
Text
|
|
78
|
+
</ListItem>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### ARIA Roles
|
|
82
|
+
|
|
83
|
+
For the purposes of accessibly adapting ListItems to certain use-cases, a `role` property has been exposed to override the default [ARIA role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques) of the item, which is `listitem`.
|
|
84
|
+
|
|
85
|
+
## Component API
|
|
86
|
+
|
|
87
|
+
<APIDocs {data} />
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button, PersonPicture, InfoBadge } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/PersonPicture/PersonPicture.svelte?sveld&raw";
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
The person picture control displays the avatar image for a person, if one is available; if not, it displays the person's initials or a generic glyph. You can additionally insert your own badge at the top of the picture, and provide your own inner content.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { PersonPicture } from "fluent-svelte";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
<Showcase repl="46c25d4df2414602878cb7a1d7d47194" columns={4}>
|
|
15
|
+
<PersonPicture src="https://thispersondoesnotexist.com/image" alt="Random person">
|
|
16
|
+
{Math.random()
|
|
17
|
+
.toString(36)
|
|
18
|
+
.replace(/[^a-z]+/g, "")
|
|
19
|
+
.toUpperCase()
|
|
20
|
+
.substr(0, 2)}
|
|
21
|
+
</PersonPicture>
|
|
22
|
+
<PersonPicture src="https://thispersondoesnotexist.com/image" alt="Random person" size={48} />
|
|
23
|
+
<PersonPicture>
|
|
24
|
+
{Math.random()
|
|
25
|
+
.toString(36)
|
|
26
|
+
.replace(/[^a-z]+/g, "")
|
|
27
|
+
.toUpperCase()
|
|
28
|
+
.substr(0, 2)}
|
|
29
|
+
<svelte:fragment slot="badge">
|
|
30
|
+
<InfoBadge>1</InfoBadge>
|
|
31
|
+
</svelte:fragment>
|
|
32
|
+
</PersonPicture>
|
|
33
|
+
<PersonPicture alt="A A A" />
|
|
34
|
+
</Showcase>
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Setting a Photo
|
|
39
|
+
|
|
40
|
+
Similarly to HTML's [`<img />`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) element, you can set the `src` property to a URL of an image.
|
|
41
|
+
|
|
42
|
+
```svelte example hideScript
|
|
43
|
+
<script>
|
|
44
|
+
import { PersonPicture } from "fluent-svelte";
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<PersonPicture src="https://source.unsplash.com/random" />
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
It's recommended for both accessibility and fallback purposes that you provide an `alt` property for the image as well. The `alt` attribute is used by screen readers to provide a description of the image to visually impaired users.
|
|
51
|
+
|
|
52
|
+
```svelte example hideScript
|
|
53
|
+
<script>
|
|
54
|
+
import { PersonPicture } from "fluent-svelte";
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<PersonPicture
|
|
58
|
+
alt="Dog runs through the snow"
|
|
59
|
+
src="https://images.unsplash.com/photo-1530126483408-aa533e55bdb2"
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Additionally, if `src` is invalid and no slot text is inserted, the alt text will be converted to initials format as a fallback.
|
|
64
|
+
|
|
65
|
+
```svelte example hideScript
|
|
66
|
+
<script>
|
|
67
|
+
import { PersonPicture } from "fluent-svelte";
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<PersonPicture src="not-a-real-domain" alt="John Smith" />
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Custom Text
|
|
74
|
+
|
|
75
|
+
If no `src` is provided, you can provide your own text to be displayed in the control. The order of display is:
|
|
76
|
+
|
|
77
|
+
1. If a valid image URL in `src` is provided, it will be displayed.
|
|
78
|
+
2. If the `src` attribute fails to display or is invalid, the text or HTML is passed into the default slot will be displayed.
|
|
79
|
+
3. If `src` is invalid, no slots are used, but an `alt` property is provided, the alt text will be converted to initials format and displayed.
|
|
80
|
+
|
|
81
|
+
```svelte example hideScript
|
|
82
|
+
<script>
|
|
83
|
+
import { PersonPicture } from "fluent-svelte";
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<div style="display: flex; gap: 12px;">
|
|
87
|
+
<PersonPicture>RDJ</PersonPicture>
|
|
88
|
+
<PersonPicture src="not-a-real-domain" alt="Robert Downey Jr." />
|
|
89
|
+
</div>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Badges
|
|
93
|
+
|
|
94
|
+
You can use the component's `badge` slot to insert an offset element at the top of the picture. It's recommended that you use the [`InfoBadge`](infobadge) component for this.
|
|
95
|
+
|
|
96
|
+
```svelte example
|
|
97
|
+
<script>
|
|
98
|
+
import { InfoBadge, PersonPicture } from "fluent-svelte";
|
|
99
|
+
|
|
100
|
+
let messages = 4;
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<PersonPicture src="https://thispersondoesnotexist.com/image" alt="John Smith">
|
|
104
|
+
<InfoBadge slot="badge">{messages}</InfoBadge>
|
|
105
|
+
</PersonPicture>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Size
|
|
109
|
+
|
|
110
|
+
You can control the dimensions of the picture in pixels by setting the `size` property. The default size is `72`.
|
|
111
|
+
|
|
112
|
+
```svelte example hideScript
|
|
113
|
+
<script>
|
|
114
|
+
import { PersonPicture } from "fluent-svelte";
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<PersonPicture size={8} />
|
|
118
|
+
<PersonPicture size={16} />
|
|
119
|
+
<PersonPicture size={32} />
|
|
120
|
+
<PersonPicture size={64} />
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Component API
|
|
124
|
+
|
|
125
|
+
<APIDocs {data} />
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ProgressRing, NumberBox } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/ProgressRing/ProgressRing.svelte?sveld&raw";
|
|
6
|
+
|
|
7
|
+
let value = Math.floor(Math.random() * 100);
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
ProgressRing provides visual feedback to to the user that a long-running operation is underway. It can mean that the user cannot interact with the app when the progress indicator is visible, and can also indicate how long the wait time might be.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { ProgressRing } from "fluent-svelte";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
<Showcase repl="">
|
|
17
|
+
<div class="ring-spacer">
|
|
18
|
+
<ProgressRing />
|
|
19
|
+
<ProgressRing bind:value />
|
|
20
|
+
</div>
|
|
21
|
+
<NumberBox
|
|
22
|
+
on:mousedown={e => e.stopPropagation()}
|
|
23
|
+
class="example-ring-input"
|
|
24
|
+
placeholder="%"
|
|
25
|
+
clearButton={false}
|
|
26
|
+
min={0}
|
|
27
|
+
max={100}
|
|
28
|
+
inline
|
|
29
|
+
bind:value
|
|
30
|
+
/>
|
|
31
|
+
</Showcase>
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Completion Value
|
|
36
|
+
|
|
37
|
+
The `value` property takes in a number between `0` to `100` that represents the percentage of a task that is completed.
|
|
38
|
+
|
|
39
|
+
```svelte example hideScript
|
|
40
|
+
<script>
|
|
41
|
+
import { ProgressRing } from "fluent-svelte";
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<ProgressRing value={50} />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
ProgressRings have two primary states - _determinate_ and _indeterminate_.
|
|
48
|
+
|
|
49
|
+
A ProgressRing is indeterminate under the following conditions:
|
|
50
|
+
|
|
51
|
+
- No `value` is provided.
|
|
52
|
+
- A `value` is passed in, but it is `undefined`, `null`, or `NaN`.
|
|
53
|
+
|
|
54
|
+
A determinate ProgressRing displays a completion percentage by filling the ring gradually, while an indeterminate ProgressRing plays a looping spinner animation.
|
|
55
|
+
|
|
56
|
+
### Size
|
|
57
|
+
|
|
58
|
+
You can control the diameter of the ring in pixels by setting the `size` property. The default size is `32`.
|
|
59
|
+
|
|
60
|
+
```svelte example hideScript
|
|
61
|
+
<script>
|
|
62
|
+
import { ProgressRing } from "fluent-svelte";
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<ProgressRing size={64} />
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Component API
|
|
69
|
+
|
|
70
|
+
<APIDocs {data} />
|
|
71
|
+
|
|
72
|
+
<style>
|
|
73
|
+
.ring-spacer {
|
|
74
|
+
display: grid;
|
|
75
|
+
grid-template-columns: 1fr 1fr;
|
|
76
|
+
grid-gap: 12px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
:global(.component-showcase .component-showcase-grid > .example-ring-input) {
|
|
80
|
+
margin-block-start: 12px;
|
|
81
|
+
inline-size: 108px;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { RadioButton, Button, InfoBar } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/RadioButton/RadioButton.svelte?sveld&raw";
|
|
6
|
+
|
|
7
|
+
let group = 1;
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
Radio buttons, also called option buttons, let users select one option from a collection of two or more mutually exclusive, but related, options. The singular behavior of a RadioButtons group distinguishes it from check boxes, which support multi-selection and deselection, or clearing.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { RadioButton } from "fluent-svelte";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
<Showcase columns={3} repl="b3c4c774b4b84f948a8a6747e5cf7226">
|
|
17
|
+
<RadioButton value={1} bind:group>Option 1</RadioButton>
|
|
18
|
+
<RadioButton value={2} bind:group>Option 2</RadioButton>
|
|
19
|
+
<RadioButton value={3} bind:group disabled>Option 3</RadioButton>
|
|
20
|
+
<RadioButton checked>RadioButton</RadioButton>
|
|
21
|
+
<RadioButton disabled>RadioButton</RadioButton>
|
|
22
|
+
<RadioButton disabled checked>RadioButton</RadioButton>
|
|
23
|
+
</Showcase>
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
`<RadioButton />` is a wrapper around HTML's `<input />` radio type. As such, the APIs share some similarities.
|
|
28
|
+
|
|
29
|
+
### Labels
|
|
30
|
+
|
|
31
|
+
Passing in content to the RadioButton's slot will cause that content to be rendered into a label for the control.
|
|
32
|
+
|
|
33
|
+
```svelte example hideScript
|
|
34
|
+
<script>
|
|
35
|
+
import { RadioButton } from "fluent-svelte";
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<RadioButton>I have a label!</RadioButton>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Value
|
|
42
|
+
|
|
43
|
+
The `value` property is used to determine the piece of data that is associated with the radio. This serves two primary purposes:
|
|
44
|
+
|
|
45
|
+
- For usage in forms, this [value](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value) is submitted with the form as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
|
|
46
|
+
- If a [group binding](#radio-groups) is used, the radio's `value` will be used to determine which radio in the group is currently selected.
|
|
47
|
+
|
|
48
|
+
```svelte example hideScript
|
|
49
|
+
<script>
|
|
50
|
+
import { RadioButton } from "fluent-svelte";
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<RadioButton value={1}>Option 1</RadioButton>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Radio Groups
|
|
57
|
+
|
|
58
|
+
Radio Buttons can be grouped together as a mutually-exclusive list of options using a _group binding_. Group bindings bind to a variable who's value corresponds to the value property of the currently selected item.
|
|
59
|
+
|
|
60
|
+
```svelte example
|
|
61
|
+
<script>
|
|
62
|
+
import { RadioButton } from "fluent-svelte";
|
|
63
|
+
|
|
64
|
+
let flavor = "chocolate";
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<RadioButton bind:group={flavor} value="chocolate">Chocolate</RadioButton>
|
|
68
|
+
<RadioButton bind:group={flavor} value="vanilla">Vanilla</RadioButton>
|
|
69
|
+
<RadioButton bind:group={flavor} value="strawberry">Strawberry</RadioButton>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
When a RadioButton is selected, it will deselect all other RadioButtons in the same group, then set the bound variable to the selected item's `value` property. If you do not wish to set a default option, the bound variable can simply be initialized without a value.
|
|
73
|
+
|
|
74
|
+
### Manually Controlling State
|
|
75
|
+
|
|
76
|
+
If `group` is not set, you also have access to a `checked` property that allows you to manually set the initial state of the Radio.
|
|
77
|
+
|
|
78
|
+
```svelte example hideScript
|
|
79
|
+
<script>
|
|
80
|
+
import { RadioButton } from "fluent-svelte";
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<RadioButton checked>I am checked by default.</RadioButton>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Component API
|
|
87
|
+
|
|
88
|
+
<APIDocs {data} />
|