@canonical/svelte-ds-app-launchpad 0.26.0 → 0.27.1-experimental.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/dist/components/NumberInput/types.d.ts +2 -2
- package/dist/components/Popover/Popover.svelte +1 -1
- package/dist/components/SearchBox/SearchBox.svelte +79 -0
- package/dist/components/SearchBox/SearchBox.svelte.d.ts +36 -0
- package/dist/components/SearchBox/common/SearchButton/SearchButton.svelte +31 -0
- package/dist/components/SearchBox/common/SearchButton/SearchButton.svelte.d.ts +5 -0
- package/dist/components/SearchBox/common/SearchButton/index.d.ts +2 -0
- package/dist/components/SearchBox/common/SearchButton/index.js +1 -0
- package/dist/components/SearchBox/common/SearchButton/styles.css +11 -0
- package/dist/components/SearchBox/common/SearchButton/types.d.ts +2 -0
- package/dist/components/SearchBox/common/SearchButton/types.js +1 -0
- package/dist/components/SearchBox/common/index.d.ts +1 -0
- package/dist/components/SearchBox/common/index.js +1 -0
- package/dist/components/SearchBox/context.d.ts +2 -0
- package/dist/components/SearchBox/context.js +2 -0
- package/dist/components/SearchBox/index.d.ts +22 -0
- package/dist/components/SearchBox/index.js +6 -0
- package/dist/components/SearchBox/styles.css +35 -0
- package/dist/components/SearchBox/types.d.ts +26 -0
- package/dist/components/SearchBox/types.js +2 -0
- package/dist/components/Select/Select.svelte +51 -0
- package/dist/components/Select/Select.svelte.d.ts +17 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Select/index.js +3 -0
- package/dist/components/Select/styles.css +162 -0
- package/dist/components/Select/types.d.ts +7 -0
- package/dist/components/Select/types.js +2 -0
- package/dist/components/SideNavigation/SideNavigation.svelte +120 -0
- package/dist/components/SideNavigation/SideNavigation.svelte.d.ts +65 -0
- package/dist/components/SideNavigation/common/ExpandToggle/ExpandToggle.svelte +14 -0
- package/dist/components/SideNavigation/common/ExpandToggle/ExpandToggle.svelte.d.ts +5 -0
- package/dist/components/SideNavigation/common/ExpandToggle/index.d.ts +2 -0
- package/dist/components/SideNavigation/common/ExpandToggle/index.js +2 -0
- package/dist/components/SideNavigation/common/ExpandToggle/styles.css +14 -0
- package/dist/components/SideNavigation/common/ExpandToggle/types.d.ts +2 -0
- package/dist/components/SideNavigation/common/ExpandToggle/types.js +1 -0
- package/dist/components/SideNavigation/common/NavigationItem/NavigationItem.svelte +33 -0
- package/dist/components/SideNavigation/common/NavigationItem/NavigationItem.svelte.d.ts +5 -0
- package/dist/components/SideNavigation/common/NavigationItem/index.d.ts +2 -0
- package/dist/components/SideNavigation/common/NavigationItem/index.js +2 -0
- package/dist/components/SideNavigation/common/NavigationItem/styles.css +52 -0
- package/dist/components/SideNavigation/common/NavigationItem/types.d.ts +16 -0
- package/dist/components/SideNavigation/common/NavigationItem/types.js +1 -0
- package/dist/components/SideNavigation/common/index.d.ts +2 -0
- package/dist/components/SideNavigation/common/index.js +2 -0
- package/dist/components/SideNavigation/index.d.ts +15 -0
- package/dist/components/SideNavigation/index.js +7 -0
- package/dist/components/SideNavigation/styles.css +124 -0
- package/dist/components/SideNavigation/types.d.ts +39 -0
- package/dist/components/SideNavigation/types.js +2 -0
- package/dist/components/TextInput/types.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.svelte +165 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +23 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/index.js +3 -0
- package/dist/components/Tooltip/styles.css +111 -0
- package/dist/components/Tooltip/types.d.ts +43 -0
- package/dist/components/Tooltip/types.js +2 -0
- package/dist/components/Tooltip/utils/ChainingManager.d.ts +18 -0
- package/dist/components/Tooltip/utils/ChainingManager.js +29 -0
- package/dist/components/Tooltip/utils/useDelayedOpen.svelte.d.ts +15 -0
- package/dist/components/Tooltip/utils/useDelayedOpen.svelte.js +42 -0
- package/dist/components/Tooltip/utils/useTooltipPosition.svelte.d.ts +24 -0
- package/dist/components/Tooltip/utils/useTooltipPosition.svelte.js +40 -0
- package/dist/components/icons/ExpandRightIcon.svelte +22 -0
- package/dist/components/icons/ExpandRightIcon.svelte.d.ts +4 -0
- package/dist/components/icons/index.d.ts +1 -0
- package/dist/components/icons/index.js +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/transitions/cssControlledFade.d.ts +9 -0
- package/dist/transitions/cssControlledFade.js +39 -0
- package/package.json +11 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ModifierFamily } from "../../modifier-families/index.js";
|
|
1
|
+
import type { ModifierFamily, ModifierFamilyValues } from "../../modifier-families/index.js";
|
|
2
2
|
import type { NumberInputPrimitiveProps } from "../common/index.js";
|
|
3
3
|
export interface NumberInputProps extends Omit<NumberInputPrimitiveProps, "type">, ModifierFamily<"severity"> {
|
|
4
|
-
density?: "dense" | "medium"
|
|
4
|
+
density?: Extract<ModifierFamilyValues["density"], "dense" | "medium">;
|
|
5
5
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!-- @canonical/generator-ds 0.10.0-experimental.4 -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { SearchBoxProps } from "./types.js";
|
|
5
|
+
import "./styles.css";
|
|
6
|
+
import { InputPrimitive } from "../common/index.js";
|
|
7
|
+
import { SearchButton } from "./common/index.js";
|
|
8
|
+
import { setSearchBoxContext } from "./context.js";
|
|
9
|
+
|
|
10
|
+
const componentCssClassName = "ds search-box";
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: className,
|
|
14
|
+
value = $bindable(),
|
|
15
|
+
children,
|
|
16
|
+
"aria-label": ariaLabel,
|
|
17
|
+
disabled,
|
|
18
|
+
shouldRenderInvalidStyles,
|
|
19
|
+
"data-testid": dataTestId,
|
|
20
|
+
...rest
|
|
21
|
+
}: SearchBoxProps = $props();
|
|
22
|
+
|
|
23
|
+
setSearchBoxContext({
|
|
24
|
+
get disabled() {
|
|
25
|
+
return disabled;
|
|
26
|
+
},
|
|
27
|
+
get "aria-label"() {
|
|
28
|
+
return ariaLabel;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<div class={[componentCssClassName, className]} data-testid={dataTestId}>
|
|
34
|
+
<InputPrimitive
|
|
35
|
+
type="search"
|
|
36
|
+
bind:value
|
|
37
|
+
aria-label={ariaLabel}
|
|
38
|
+
{disabled}
|
|
39
|
+
class={{ "no-invalid-styles": !shouldRenderInvalidStyles }}
|
|
40
|
+
{...rest}
|
|
41
|
+
/>
|
|
42
|
+
{#if children}
|
|
43
|
+
{@render children()}
|
|
44
|
+
{:else}
|
|
45
|
+
<SearchButton />
|
|
46
|
+
{/if}
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<!-- @component
|
|
50
|
+
`SearchBox` is a text input field designed for search functionality.
|
|
51
|
+
|
|
52
|
+
By default, it renders an input and a submit button (`SearchBox.SearchButton`).
|
|
53
|
+
You can override the default button by passing `children`.
|
|
54
|
+
|
|
55
|
+
When `SearchBox.SearchButton` is used inside `SearchBox`, it inherits `aria-label` and `disabled` from `SearchBox` context by default. You can still override those values directly on `SearchBox.SearchButton` when needed.
|
|
56
|
+
|
|
57
|
+
## Example Usage
|
|
58
|
+
### Basic Example
|
|
59
|
+
```svelte
|
|
60
|
+
<SearchBox aria-label="Search articles" placeholder="Ubuntu" />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Customized SearchButton
|
|
64
|
+
```svelte
|
|
65
|
+
<SearchBox aria-label="Search articles" placeholder="Ubuntu">
|
|
66
|
+
<SearchBox.SearchButton onclick={handleClick} aria-label="Run search" />
|
|
67
|
+
</SearchBox>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### As a search landmark
|
|
71
|
+
To make the `SearchBox` a search landmark wrap it in a [`<form role="search">`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/search_role) or [`<search>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/search)
|
|
72
|
+
```svelte
|
|
73
|
+
<search>
|
|
74
|
+
<form>
|
|
75
|
+
<SearchBox aria-label="Articles" name="q" />
|
|
76
|
+
</form>
|
|
77
|
+
</search>
|
|
78
|
+
```
|
|
79
|
+
-->
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SearchBoxProps } from "./types.js";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
/**
|
|
4
|
+
* `SearchBox` is a text input field designed for search functionality.
|
|
5
|
+
*
|
|
6
|
+
* By default, it renders an input and a submit button (`SearchBox.SearchButton`).
|
|
7
|
+
* You can override the default button by passing `children`.
|
|
8
|
+
*
|
|
9
|
+
* When `SearchBox.SearchButton` is used inside `SearchBox`, it inherits `aria-label` and `disabled` from `SearchBox` context by default. You can still override those values directly on `SearchBox.SearchButton` when needed.
|
|
10
|
+
*
|
|
11
|
+
* ## Example Usage
|
|
12
|
+
* ### Basic Example
|
|
13
|
+
* ```svelte
|
|
14
|
+
* <SearchBox aria-label="Search articles" placeholder="Ubuntu" />
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ### Customized SearchButton
|
|
18
|
+
* ```svelte
|
|
19
|
+
* <SearchBox aria-label="Search articles" placeholder="Ubuntu">
|
|
20
|
+
* <SearchBox.SearchButton onclick={handleClick} aria-label="Run search" />
|
|
21
|
+
* </SearchBox>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ### As a search landmark
|
|
25
|
+
* To make the `SearchBox` a search landmark wrap it in a [`<form role="search">`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/search_role) or [`<search>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/search)
|
|
26
|
+
* ```svelte
|
|
27
|
+
* <search>
|
|
28
|
+
* <form>
|
|
29
|
+
* <SearchBox aria-label="Articles" name="q" />
|
|
30
|
+
* </form>
|
|
31
|
+
* </search>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare const SearchBox: import("svelte").Component<SearchBoxProps, {}, "value">;
|
|
35
|
+
type SearchBox = ReturnType<typeof SearchBox>;
|
|
36
|
+
export default SearchBox;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SearchIcon } from "@canonical/svelte-icons";
|
|
3
|
+
import { ButtonPrimitive } from "../../../common/index.js";
|
|
4
|
+
import type { SearchButtonProps } from "./types.js";
|
|
5
|
+
import "./styles.css";
|
|
6
|
+
import { getSearchBoxContext } from "../../context.js";
|
|
7
|
+
|
|
8
|
+
const componentCssClassName = "ds search-box-search-button";
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
class: className,
|
|
12
|
+
type = "submit",
|
|
13
|
+
disabled,
|
|
14
|
+
"aria-label": ariaLabel,
|
|
15
|
+
...rest
|
|
16
|
+
}: SearchButtonProps = $props();
|
|
17
|
+
|
|
18
|
+
const searchBoxContext = getSearchBoxContext();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<ButtonPrimitive
|
|
22
|
+
{type}
|
|
23
|
+
class={[componentCssClassName, className]}
|
|
24
|
+
disabled={disabled !== undefined ? disabled : searchBoxContext.disabled}
|
|
25
|
+
aria-label={ariaLabel !== undefined
|
|
26
|
+
? ariaLabel
|
|
27
|
+
: searchBoxContext["aria-label"]}
|
|
28
|
+
{...rest}
|
|
29
|
+
>
|
|
30
|
+
<SearchIcon />
|
|
31
|
+
</ButtonPrimitive>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SearchButton } from "./SearchButton.svelte";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.ds.search-box-search-button.button-primitive {
|
|
2
|
+
justify-self: end;
|
|
3
|
+
display: grid;
|
|
4
|
+
place-items: center;
|
|
5
|
+
padding: 0;
|
|
6
|
+
--color-background-button-hover: transparent;
|
|
7
|
+
--color-background-button-active: transparent;
|
|
8
|
+
|
|
9
|
+
width: var(--dimension-width-search-box-button);
|
|
10
|
+
margin-inline-end: var(--dimension-gap-search-box);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SearchButton/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SearchButton/index.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SearchButton } from "./common/index.js";
|
|
2
|
+
import { default as SearchBoxRoot } from "./SearchBox.svelte";
|
|
3
|
+
declare const SearchBox: typeof SearchBoxRoot & {
|
|
4
|
+
/**
|
|
5
|
+
* `SearchButton` is the button companion for `SearchBox`.
|
|
6
|
+
*
|
|
7
|
+
* It is available as `SearchBox.SearchButton` and is intended to be used inside `SearchBox` when you want to customize the default button behavior.
|
|
8
|
+
*
|
|
9
|
+
* `disabled` and `aria-label` props can be passed directly to `SearchButton`, but if they are not provided they will reflect their respective values from `SearchBox` context.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```svelte
|
|
13
|
+
* <SearchBox aria-label="Search articles">
|
|
14
|
+
* <SearchBox.SearchButton onclick={handleClick} disabled />
|
|
15
|
+
* </SearchBox>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
SearchButton: typeof SearchButton;
|
|
19
|
+
};
|
|
20
|
+
export type { SearchButtonProps as SearchBoxSearchButtonProps } from "./common/index.js";
|
|
21
|
+
export type { SearchBoxProps } from "./types.js";
|
|
22
|
+
export { SearchBox };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.ds.search-box {
|
|
2
|
+
--dimension-width-search-box-button: var(--lp-dimension-size-l);
|
|
3
|
+
--dimension-gap-search-box: var(--lp-dimension-spacing-inline-xs);
|
|
4
|
+
|
|
5
|
+
display: grid;
|
|
6
|
+
grid-template-areas: "main";
|
|
7
|
+
|
|
8
|
+
> * {
|
|
9
|
+
grid-area: main;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
> input {
|
|
13
|
+
padding-inline-end: calc(
|
|
14
|
+
2 *
|
|
15
|
+
var(--dimension-gap-search-box) +
|
|
16
|
+
var(--dimension-width-search-box-button)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
&::-webkit-search-cancel-button {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.no-invalid-styles {
|
|
24
|
+
--color-background-input-invalid: var(--color-background-input);
|
|
25
|
+
--color-background-input-invalid-hover: var(
|
|
26
|
+
--color-background-input-hover
|
|
27
|
+
);
|
|
28
|
+
--color-background-input-invalid-active: var(
|
|
29
|
+
--color-background-input-active
|
|
30
|
+
);
|
|
31
|
+
--color-border-input-invalid: var(--color-border-input);
|
|
32
|
+
--color-outline-input-invalid: var(--color-outline-input);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
import type { TextInputPrimitiveProps } from "../common/index.js";
|
|
4
|
+
export interface SearchBoxProps extends Omit<TextInputPrimitiveProps, "type"> {
|
|
5
|
+
/**
|
|
6
|
+
* The accessible name for the input.
|
|
7
|
+
*
|
|
8
|
+
* A search input's purpose is usually clear for sighted users, but screen reader users may not have the same context. Providing an accessible name helps ensure that all users understand the purpose of the input (see: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/search#search_form_labels_and_accessibility).
|
|
9
|
+
*/
|
|
10
|
+
"aria-label": string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to apply the invalid styles to the input when it fails native validation (`:user-invalid`) or `aria-invalid="true"` is set.
|
|
13
|
+
*
|
|
14
|
+
* @default false
|
|
15
|
+
* This is opt-in because search landmarks often have submission requirements, such as `required` and `minlength`, where you may want to block submission without showing a visual invalid state.
|
|
16
|
+
*/
|
|
17
|
+
shouldRenderInvalidStyles?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The content to render instead of the default `SearchBox.SearchButton`. This is useful when you want to customize the default button behavior, such as adding an `onclick` handler.
|
|
20
|
+
*/
|
|
21
|
+
children?: Snippet<[]>;
|
|
22
|
+
}
|
|
23
|
+
export type SearchBoxContext = {
|
|
24
|
+
disabled: HTMLInputAttributes["disabled"];
|
|
25
|
+
"aria-label": string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!-- @canonical/generator-ds 0.10.0-experimental.3 -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { ChevronDownIcon } from "@canonical/svelte-icons";
|
|
5
|
+
import type { SelectProps } from "./types.js";
|
|
6
|
+
import "./styles.css";
|
|
7
|
+
|
|
8
|
+
const componentCssClassName = "ds select";
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
class: className,
|
|
12
|
+
ref = $bindable(),
|
|
13
|
+
value = $bindable(),
|
|
14
|
+
children,
|
|
15
|
+
severity,
|
|
16
|
+
density,
|
|
17
|
+
"data-testid": dataTestId,
|
|
18
|
+
...rest
|
|
19
|
+
}: SelectProps = $props();
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
The wrapper is needed to position the chevron icon correctly.
|
|
24
|
+
TODO: Remove the wrapper when:
|
|
25
|
+
- ideally [Customizable select elements](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select) are supported across browsers.
|
|
26
|
+
- alternatively, anchor positioning support is widespread enough to position the chevron icon without needing a wrapper element.
|
|
27
|
+
-->
|
|
28
|
+
<div
|
|
29
|
+
class={[componentCssClassName, className, severity, density]}
|
|
30
|
+
data-testid={dataTestId}
|
|
31
|
+
>
|
|
32
|
+
<select bind:value bind:this={ref} {...rest}>
|
|
33
|
+
{@render children?.()}
|
|
34
|
+
</select>
|
|
35
|
+
{#if !rest.multiple}
|
|
36
|
+
<ChevronDownIcon class="chevron" />
|
|
37
|
+
{/if}
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- @component
|
|
41
|
+
`Select` is a styled wrapper around the native HTML `<select>` element.
|
|
42
|
+
|
|
43
|
+
## Example Usage
|
|
44
|
+
```svelte
|
|
45
|
+
<Select bind:value={valueState}>
|
|
46
|
+
<option value="1">Option 1</option>
|
|
47
|
+
<option value="2">Option 2</option>
|
|
48
|
+
<option value="3">Option 3</option>
|
|
49
|
+
</Select>
|
|
50
|
+
```
|
|
51
|
+
-->
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SelectProps } from "./types.js";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
/**
|
|
4
|
+
* `Select` is a styled wrapper around the native HTML `<select>` element.
|
|
5
|
+
*
|
|
6
|
+
* ## Example Usage
|
|
7
|
+
* ```svelte
|
|
8
|
+
* <Select bind:value={valueState}>
|
|
9
|
+
* <option value="1">Option 1</option>
|
|
10
|
+
* <option value="2">Option 2</option>
|
|
11
|
+
* <option value="3">Option 3</option>
|
|
12
|
+
* </Select>
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const Select: import("svelte").Component<SelectProps, {}, "value" | "ref">;
|
|
16
|
+
type Select = ReturnType<typeof Select>;
|
|
17
|
+
export default Select;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
.ds.select {
|
|
2
|
+
--color-background-select-input-hover: var(
|
|
3
|
+
--lp-color-background-secondary-hover-context,
|
|
4
|
+
var(--lp-color-background-hover)
|
|
5
|
+
);
|
|
6
|
+
--color-background-select-input-active: var(
|
|
7
|
+
--lp-color-background-secondary-active-context,
|
|
8
|
+
var(--lp-color-background-active)
|
|
9
|
+
);
|
|
10
|
+
--color-background-select-input: var(
|
|
11
|
+
--lp-color-background-secondary-context,
|
|
12
|
+
var(--lp-color-background-input)
|
|
13
|
+
);
|
|
14
|
+
--dimension-padding-inline-select-input: var(
|
|
15
|
+
--lp-dimension-spacing-inline-xs
|
|
16
|
+
);
|
|
17
|
+
--dimension-padding-block-select-input: var(
|
|
18
|
+
--lp-dimension-padding-block-context,
|
|
19
|
+
var(--lp-dimension-spacing-block-xxs)
|
|
20
|
+
);
|
|
21
|
+
--color-border-select-input: var(
|
|
22
|
+
--lp-color-border-secondary-context,
|
|
23
|
+
var(--lp-color-border-high-contrast)
|
|
24
|
+
);
|
|
25
|
+
--color-outline-select-input: var(
|
|
26
|
+
--lp-color-border-secondary-context,
|
|
27
|
+
var(--lp-color-border-focus)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
color: var(--lp-color-text-default);
|
|
31
|
+
font: var(--lp-typography-paragraph-default);
|
|
32
|
+
|
|
33
|
+
display: inline-grid;
|
|
34
|
+
align-items: center;
|
|
35
|
+
grid-template-areas: "select";
|
|
36
|
+
|
|
37
|
+
> * {
|
|
38
|
+
grid-area: select;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
> .chevron {
|
|
42
|
+
justify-self: end;
|
|
43
|
+
margin-inline-end: var(--dimension-padding-inline-select-input);
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
> select {
|
|
48
|
+
appearance: none;
|
|
49
|
+
border: none;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
color: inherit;
|
|
52
|
+
font: inherit;
|
|
53
|
+
|
|
54
|
+
padding-inline-start: var(--dimension-padding-inline-select-input);
|
|
55
|
+
/* Padding + gap + icon size */
|
|
56
|
+
padding-inline-end: calc(
|
|
57
|
+
var(--dimension-padding-inline-select-input) +
|
|
58
|
+
var(--lp-dimension-spacing-inline-xxxs) +
|
|
59
|
+
1em
|
|
60
|
+
);
|
|
61
|
+
padding-block: var(--dimension-padding-block-select-input);
|
|
62
|
+
border-block-end: var(--lp-dimension-stroke-thickness-default) solid
|
|
63
|
+
var(--color-border-select-input);
|
|
64
|
+
background-color: var(--color-background-select-input);
|
|
65
|
+
outline-color: var(--color-outline-select-input);
|
|
66
|
+
border-radius: var(--lp-dimension-radius-none);
|
|
67
|
+
|
|
68
|
+
transition-duration: var(--lp-transition-duration-snap);
|
|
69
|
+
transition-property: background-color, border-color, outline-color;
|
|
70
|
+
transition-timing-function: var(--lp-transition-timing-ease-in);
|
|
71
|
+
|
|
72
|
+
&:not(:disabled) {
|
|
73
|
+
&:hover {
|
|
74
|
+
background-color: var(--color-background-select-input-hover);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:active,
|
|
78
|
+
&:focus {
|
|
79
|
+
background-color: var(--color-background-select-input-active);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&:disabled {
|
|
84
|
+
cursor: not-allowed;
|
|
85
|
+
opacity: var(--lp-opacity-muted);
|
|
86
|
+
|
|
87
|
+
+ .chevron {
|
|
88
|
+
opacity: var(--lp-opacity-muted);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&:user-invalid,
|
|
93
|
+
&[aria-invalid="true"] {
|
|
94
|
+
--color-background-select-input: var(
|
|
95
|
+
--lp-color-background-negative-default
|
|
96
|
+
);
|
|
97
|
+
border-color: var(--lp-color-border-negative);
|
|
98
|
+
outline-color: var(--lp-color-border-negative);
|
|
99
|
+
|
|
100
|
+
&:hover {
|
|
101
|
+
background-color: var(--lp-color-background-negative-hover);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&:active,
|
|
105
|
+
&:focus {
|
|
106
|
+
background-color: var(--lp-color-background-negative-active);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&:not([multiple]) {
|
|
111
|
+
option {
|
|
112
|
+
/*
|
|
113
|
+
FIXME(steciuk): The colors currently used for the select background have some baked-in transparency.
|
|
114
|
+
This doesn't play well with how the select element is rendered in Chrome, making the options looked washed out and with very low contrast. This is a temporary workaround that aims to strip the transparency from the color while keeping similar visuals.
|
|
115
|
+
|
|
116
|
+
A better solution would be to update the design tokens to use solid colors, but the currently tokens and modifiers system are soon to be replaced anyway, so it might not be worth the effort.
|
|
117
|
+
*/
|
|
118
|
+
background-color: var(--lp-color-background-default);
|
|
119
|
+
/* biome-ignore lint/suspicious/noDuplicateProperties: Fallback for older chrome versions */
|
|
120
|
+
background-color: color-mix(
|
|
121
|
+
in srgb,
|
|
122
|
+
rgb(from var(--color-background-select-input) r g b / 1) 20%,
|
|
123
|
+
var(--lp-color-background-default) 80%
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&[multiple] {
|
|
129
|
+
padding: 0;
|
|
130
|
+
|
|
131
|
+
option {
|
|
132
|
+
padding-block: var(--dimension-padding-block-select-input);
|
|
133
|
+
padding-inline: var(--dimension-padding-inline-select-input);
|
|
134
|
+
|
|
135
|
+
&:checked {
|
|
136
|
+
background-color: var(--color-background-select-input-active);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&.base {
|
|
143
|
+
--color-background-select-input-hover: var(
|
|
144
|
+
--lp-color-background-neutral-hover
|
|
145
|
+
);
|
|
146
|
+
--color-background-select-input-active: var(
|
|
147
|
+
--lp-color-background-neutral-active
|
|
148
|
+
);
|
|
149
|
+
--color-background-select-input: transparent;
|
|
150
|
+
|
|
151
|
+
> select {
|
|
152
|
+
border: none;
|
|
153
|
+
|
|
154
|
+
&:not([multiple]) {
|
|
155
|
+
option {
|
|
156
|
+
/* FIXME(steciuk): Pt. 2 of the transparency workaround */
|
|
157
|
+
background-color: var(--lp-color-background-default);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HTMLSelectAttributes } from "svelte/elements";
|
|
2
|
+
import type { ModifierFamilyValues } from "../../modifier-families/index.js";
|
|
3
|
+
export interface SelectProps extends HTMLSelectAttributes {
|
|
4
|
+
ref?: HTMLSelectElement;
|
|
5
|
+
density?: Extract<ModifierFamilyValues["density"], "dense" | "medium">;
|
|
6
|
+
severity?: ModifierFamilyValues["severity"] | "base";
|
|
7
|
+
}
|