@swr-data-lab/components 2.41.0 → 2.42.1

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.
@@ -7,7 +7,7 @@ export {};
7
7
  </div>
8
8
 
9
9
  <style>.container {
10
- --margin: 16px;
10
+ --margin: max(16px, calc((100vw - 1312px) / 2));
11
11
  --column-gap: 16px;
12
12
  --grid-width: min(calc(100vw - var(--margin) * 2), 1312px);
13
13
  --column-width: calc(
@@ -65,9 +65,4 @@ export {};
65
65
  .bleed {
66
66
  margin-left: calc((var(--column-width) + var(--column-gap)) * -2 - var(--margin));
67
67
  }
68
- }
69
- @media (min-width: 1280px) {
70
- .bleed {
71
- margin-left: calc((var(--column-width) + var(--column-gap)) * -2 - max(0px, (100vw - 1312px) / 2));
72
- }
73
68
  }</style>
@@ -32,7 +32,7 @@ let cols = $derived.by(() => {
32
32
  max-width: none;
33
33
  }
34
34
  .col {
35
- background: rgb(104, 120, 179);
35
+ background: rgba(104, 120, 179, 60%);
36
36
  flex-grow: 0;
37
37
  &:first-child {
38
38
  border-left: 0;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">import FormLabel from '../FormLabel/FormLabel.svelte';
2
- let { label, options, size = 'default', hideLabel = false, value = $bindable(null), onchange } = $props();
2
+ let { label, options, size = 'default', hideLabel = false, layout = 'auto', value = $bindable(null), onchange } = $props();
3
3
  const groupId = $props.id();
4
4
  const groupName = 'select-' + groupId;
5
5
  function optionToID(o) {
@@ -11,7 +11,12 @@ function optionToID(o) {
11
11
  <div class="legend" class:hidden={hideLabel}>
12
12
  <FormLabel as="legend">{label}</FormLabel>
13
13
  </div>
14
- <ul>
14
+ <ul
15
+ class:layout-row={layout === 'row'}
16
+ class:layout-column={layout === 'column'}
17
+ class:layout-auto={layout === 'auto'}
18
+ role="list"
19
+ >
15
20
  {#each options as o (o)}
16
21
  <li class:is-selected={o === value}>
17
22
  <label for={optionToID(o)}>
@@ -44,10 +49,11 @@ ul {
44
49
  width: 100%;
45
50
  display: flex;
46
51
  flex-direction: column;
47
- overflow: hidden;
52
+ overflow-x: auto;
48
53
  padding: 0;
49
54
  margin: 0;
50
- border: 1px solid var(--color-textSecondary);
55
+ border-top: 1px solid var(--color-textSecondary);
56
+ border-left: 1px solid var(--color-textSecondary);
51
57
  color: var(--color-textPrimary);
52
58
  background: var(--color-surfaceFill);
53
59
  border-radius: var(--br-small);
@@ -57,13 +63,21 @@ ul {
57
63
  flex-flow: row;
58
64
  }
59
65
  }
66
+ ul.layout-row {
67
+ flex-flow: row;
68
+ }
69
+ ul.layout-column {
70
+ flex-direction: column;
71
+ }
60
72
 
61
73
  li {
62
74
  display: contents;
63
75
  }
64
76
  li:last-child label {
65
- border-right: 0;
66
- border-bottom: 0;
77
+ border-bottom-right-radius: var(--br-small);
78
+ }
79
+ li:first-child label {
80
+ border-top-left-radius: var(--br-small);
67
81
  }
68
82
 
69
83
  input {
@@ -82,36 +96,41 @@ label {
82
96
  line-height: 1;
83
97
  white-space: nowrap;
84
98
  padding: 0 1em;
85
- cursor: pointer;
86
99
  margin: 0;
87
- align-items: center;
100
+ cursor: pointer;
88
101
  display: flex;
102
+ justify-content: center;
103
+ align-items: center;
89
104
  color: currentColor;
90
105
  position: relative;
91
106
  transition: var(--fast);
92
107
  text-underline-offset: 0.1em;
93
- border-right: 1px solid var(--color-textSecondary);
94
108
  height: 2.25em;
109
+ border-right: 1px solid var(--color-textSecondary);
110
+ border-bottom: 1px solid var(--color-textSecondary);
111
+ flex-grow: 1;
95
112
  }
96
113
  @media (min-width: 425px) {
97
114
  label {
98
- justify-content: center;
99
- padding: 0 1em;
100
115
  flex-basis: 0;
101
- flex-grow: 1;
102
- border-bottom: 0;
103
116
  }
104
117
  }
105
- @media (min-width: 425px) {
106
- label {
107
- height: 2.5em;
108
- }
118
+ .layout-row label {
119
+ flex-basis: 0;
109
120
  }
110
- label:hover, label:focus-visible {
111
- text-decoration: underline;
112
- text-decoration-color: var(--color-textSecondary);
121
+ .layout-column label {
122
+ flex-basis: auto;
113
123
  }
114
124
  .is-selected label {
115
125
  background: var(--color-surfaceHover);
116
126
  font-weight: 700;
127
+ }
128
+ @media (prefers-color-scheme: dark) {
129
+ .is-selected label {
130
+ background: var(--gray-dark-2);
131
+ }
132
+ }
133
+ label:hover, label:focus-visible {
134
+ text-decoration: underline;
135
+ text-decoration-color: var(--color-textSecondary);
117
136
  }</style>
@@ -11,7 +11,14 @@ interface SwitcherProps {
11
11
  * Display size
12
12
  */
13
13
  size?: 'default' | 'small';
14
+ /**
15
+ * Hide the main label visually
16
+ */
14
17
  hideLabel?: boolean;
18
+ /**
19
+ * Force the options to be displayed in a row (even on small screens)
20
+ */
21
+ layout?: 'row' | 'column' | 'auto';
15
22
  /**
16
23
  * The currently-selected option (bindable)
17
24
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swr-data-lab/components",
3
3
  "description": "SWR Data Lab component library",
4
- "version": "2.41.0",
4
+ "version": "2.42.1",
5
5
  "author": "SWR Data Lab",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",