@charcoal-ui/react 6.0.0-rc.1 → 6.0.0-rc.3
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/Carousel/CarouselItem.d.ts +10 -0
- package/dist/components/Carousel/CarouselItem.d.ts.map +1 -0
- package/dist/components/Carousel/carouselStore.d.ts +25 -0
- package/dist/components/Carousel/carouselStore.d.ts.map +1 -0
- package/dist/components/Carousel/index.d.ts +61 -0
- package/dist/components/Carousel/index.d.ts.map +1 -0
- package/dist/components/Carousel/intersectionObserver.d.ts +7 -0
- package/dist/components/Carousel/intersectionObserver.d.ts.map +1 -0
- package/dist/components/Carousel/resizeObserver.d.ts +6 -0
- package/dist/components/Carousel/resizeObserver.d.ts.map +1 -0
- package/dist/components/Carousel/store.d.ts +7 -0
- package/dist/components/Carousel/store.d.ts.map +1 -0
- package/dist/components/Carousel/useCarouselScroller.d.ts +18 -0
- package/dist/components/Carousel/useCarouselScroller.d.ts.map +1 -0
- package/dist/components/Icon/index.d.ts +1 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +319 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/layered.css +319 -1
- package/dist/layered.css.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/fixtures/legacy-v1-index.css +1836 -0
- package/src/__tests__/token-v1-compat.test.ts +118 -0
- package/src/__tests__/token-v1-remap.test.ts +133 -0
- package/src/components/Carousel/CarouselItem.tsx +56 -0
- package/src/components/Carousel/MIGRATION.md +117 -0
- package/src/components/Carousel/Migration.mdx +8 -0
- package/src/components/Carousel/__snapshots__/index.css.snap +274 -0
- package/src/components/Carousel/carouselStore.test.ts +38 -0
- package/src/components/Carousel/carouselStore.ts +48 -0
- package/src/components/Carousel/index.css +274 -0
- package/src/components/Carousel/index.story.tsx +169 -0
- package/src/components/Carousel/index.test.tsx +666 -0
- package/src/components/Carousel/index.tsx +278 -0
- package/src/components/Carousel/intersectionObserver.test.ts +68 -0
- package/src/components/Carousel/intersectionObserver.ts +58 -0
- package/src/components/Carousel/resizeObserver.test.ts +60 -0
- package/src/components/Carousel/resizeObserver.ts +35 -0
- package/src/components/Carousel/store.test.ts +25 -0
- package/src/components/Carousel/store.ts +27 -0
- package/src/components/Carousel/useCarouselScroller.ts +158 -0
- package/src/components/Icon/index.tsx +2 -1
- package/src/components/Modal/__snapshots__/index.css.snap +1 -1
- package/src/components/Modal/index.css +1 -1
- package/src/index.ts +12 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
.charcoal-carousel {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.charcoal-carousel[data-full-width='true'] {
|
|
7
|
+
width: 100vw;
|
|
8
|
+
margin-inline: calc(50% - 50vw);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.charcoal-carousel__viewport {
|
|
12
|
+
position: relative;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.charcoal-carousel__scroller {
|
|
16
|
+
position: relative;
|
|
17
|
+
display: flex;
|
|
18
|
+
gap: 24px;
|
|
19
|
+
overflow-x: auto;
|
|
20
|
+
overflow-y: hidden;
|
|
21
|
+
overscroll-behavior-x: contain;
|
|
22
|
+
scroll-behavior: smooth;
|
|
23
|
+
scrollbar-width: none;
|
|
24
|
+
outline: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.charcoal-carousel__scroller::-webkit-scrollbar {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.charcoal-carousel__scroller[data-focus-visible] {
|
|
32
|
+
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.charcoal-carousel[data-size='S'] .charcoal-carousel__scroller {
|
|
36
|
+
gap: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* スクロールスナップ type は prop(scrollSnap.type)で scroller に出し分ける。
|
|
40
|
+
align は基底 .charcoal-carousel__item の後(後述)に置く(no-descending-specificity 回避)。
|
|
41
|
+
未指定時の既定(M=none / S=mandatory / align=center)は JS 側で data 属性に解決する。 */
|
|
42
|
+
|
|
43
|
+
.charcoal-carousel[data-scroll-snap-type='none'] .charcoal-carousel__scroller {
|
|
44
|
+
scroll-snap-type: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.charcoal-carousel[data-scroll-snap-type='proximity'] .charcoal-carousel__scroller {
|
|
48
|
+
scroll-snap-type: x proximity;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.charcoal-carousel[data-scroll-snap-type='mandatory'] .charcoal-carousel__scroller {
|
|
52
|
+
scroll-snap-type: x mandatory;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* グラデーション: はみ出してスクロール可能な側のみ、端のアイテムを背景色(白)へ
|
|
56
|
+
フェードさせる。mask による透過ではなく、72px の「背景色→透明」オーバーレイを
|
|
57
|
+
ビューポートに重ねて白で覆う。スクロール可能な側だけ data-can-prev/next で出し分ける。 */
|
|
58
|
+
|
|
59
|
+
.charcoal-carousel[data-has-gradient='true'] .charcoal-carousel__viewport::before, .charcoal-carousel[data-has-gradient='true'] .charcoal-carousel__viewport::after {
|
|
60
|
+
content: '';
|
|
61
|
+
position: absolute;
|
|
62
|
+
top: 0;
|
|
63
|
+
bottom: 0;
|
|
64
|
+
width: 72px;
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
opacity: 0;
|
|
67
|
+
transition: 0.2s opacity;
|
|
68
|
+
z-index: 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.charcoal-carousel[data-has-gradient='true'] .charcoal-carousel__viewport::before {
|
|
72
|
+
left: 0;
|
|
73
|
+
background: linear-gradient(to right, #fff, transparent);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.charcoal-carousel[data-has-gradient='true'] .charcoal-carousel__viewport::after {
|
|
77
|
+
right: 0;
|
|
78
|
+
background: linear-gradient(to left, #fff, transparent);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.charcoal-carousel[data-has-gradient='true'][data-can-prev='true'] .charcoal-carousel__viewport::before {
|
|
82
|
+
opacity: 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.charcoal-carousel[data-has-gradient='true'][data-can-next='true'] .charcoal-carousel__viewport::after {
|
|
86
|
+
opacity: 1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.charcoal-carousel__item {
|
|
90
|
+
flex: 0 0 auto;
|
|
91
|
+
min-width: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.charcoal-carousel[data-size='S'] .charcoal-carousel__item {
|
|
95
|
+
flex: 0 0 100%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* scroll-snap-align は prop(scrollSnap.align)で出し分ける。基底 .charcoal-carousel__item
|
|
99
|
+
より後に置くことで no-descending-specificity を回避する。 */
|
|
100
|
+
|
|
101
|
+
.charcoal-carousel[data-scroll-snap-align='center'] .charcoal-carousel__item {
|
|
102
|
+
scroll-snap-align: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.charcoal-carousel[data-scroll-snap-align='start'] .charcoal-carousel__item {
|
|
106
|
+
scroll-snap-align: start;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* ── Navigation Buttons (charcoal IconButton, variant=Overlay size=S) ── */
|
|
110
|
+
|
|
111
|
+
/* マスクと同じ 72px 1fr 72px グリッド。各ボタンは 72px ゾーンの中央に置く。 */
|
|
112
|
+
|
|
113
|
+
.charcoal-carousel__navigation {
|
|
114
|
+
position: absolute;
|
|
115
|
+
inset: 0;
|
|
116
|
+
pointer-events: none;
|
|
117
|
+
display: grid;
|
|
118
|
+
grid-template-columns: 72px 1fr 72px;
|
|
119
|
+
align-items: center;
|
|
120
|
+
/* 白フェード(z-index: 1)より上にボタンを表示する */
|
|
121
|
+
z-index: 2;
|
|
122
|
+
/* sandbox 同様、通常は隠してカルーセル hover 時にフェードイン表示する。 */
|
|
123
|
+
opacity: 0;
|
|
124
|
+
transition: 0.4s opacity;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.charcoal-carousel__navigation[data-visible='false'] {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* hover で表示。キーボード操作でも到達できるよう focus-within でも表示する。 */
|
|
132
|
+
|
|
133
|
+
.charcoal-carousel:hover .charcoal-carousel__navigation, .charcoal-carousel:focus-within .charcoal-carousel__navigation {
|
|
134
|
+
opacity: 1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.charcoal-carousel__navigation__item {
|
|
138
|
+
pointer-events: auto;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.charcoal-carousel__navigation__item[data-direction='prev'] {
|
|
142
|
+
grid-column: 1;
|
|
143
|
+
justify-self: center;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.charcoal-carousel__navigation__item[data-direction='next'] {
|
|
147
|
+
grid-column: 3;
|
|
148
|
+
justify-self: center;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* スクロール端では非表示。IconButton の disabled スタイル(opacity:0.32)より
|
|
152
|
+
高い詳細度で打ち消すため、ルートを前置する。 */
|
|
153
|
+
|
|
154
|
+
.charcoal-carousel .charcoal-carousel__navigation__item[data-hidden='true'] {
|
|
155
|
+
opacity: 0;
|
|
156
|
+
pointer-events: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* タッチデバイスではナビゲーションボタンを出さず、スワイプ操作に委ねる。 */
|
|
160
|
+
|
|
161
|
+
@media (hover: none) and (pointer: coarse) {
|
|
162
|
+
|
|
163
|
+
.charcoal-carousel__navigation {
|
|
164
|
+
display: none;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* ── Indicator: JS Fallback ── */
|
|
169
|
+
|
|
170
|
+
.charcoal-carousel__indicator {
|
|
171
|
+
display: flex;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
align-items: center;
|
|
174
|
+
height: 40px;
|
|
175
|
+
gap: 8px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.charcoal-carousel__indicator[data-visible='false'] {
|
|
179
|
+
display: none;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.charcoal-carousel__indicator__item {
|
|
183
|
+
appearance: none;
|
|
184
|
+
box-sizing: border-box;
|
|
185
|
+
width: 8px;
|
|
186
|
+
height: 8px;
|
|
187
|
+
padding: 0;
|
|
188
|
+
border: 0;
|
|
189
|
+
border-radius: 50%;
|
|
190
|
+
background-color: var(--charcoal-color-text-tertiary-default);
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
transition: 0.2s background-color;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.charcoal-carousel__indicator__item:hover {
|
|
196
|
+
background-color: var(--charcoal-color-text-secondary-default);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.charcoal-carousel__indicator__item:focus-visible {
|
|
200
|
+
outline: 2px solid rgba(0, 150, 250, 0.56);
|
|
201
|
+
outline-offset: 2px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.charcoal-carousel__indicator__item[data-active='true'] {
|
|
205
|
+
background-color: var(--charcoal-color-text-default);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* ── CSS Scroll Markers (progressive enhancement) ── */
|
|
209
|
+
|
|
210
|
+
/* CSS Scroll Markers / Anchor Positioning は新しい仕様で、stylelint がプロパティ・
|
|
211
|
+
擬似要素・擬似クラスを未知と判定するため、この @supports ブロックでは該当ルールを無効化する。 */
|
|
212
|
+
/* stylelint-disable property-no-unknown, selector-pseudo-element-no-unknown, selector-pseudo-class-no-unknown */
|
|
213
|
+
|
|
214
|
+
@supports (scroll-marker-group: after) {
|
|
215
|
+
|
|
216
|
+
.charcoal-carousel[data-indicator='true'] {
|
|
217
|
+
padding-bottom: 40px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.charcoal-carousel__scroller {
|
|
221
|
+
anchor-name: --charcoal-carousel;
|
|
222
|
+
scroll-marker-group: after;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.charcoal-carousel__scroller::scroll-button(*) {
|
|
226
|
+
content: none;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.charcoal-carousel__scroller::scroll-marker-group {
|
|
230
|
+
display: flex;
|
|
231
|
+
justify-content: center;
|
|
232
|
+
align-items: center;
|
|
233
|
+
height: 40px;
|
|
234
|
+
gap: 8px;
|
|
235
|
+
position: absolute;
|
|
236
|
+
position-anchor: --charcoal-carousel;
|
|
237
|
+
top: anchor(bottom);
|
|
238
|
+
justify-self: anchor-center;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.charcoal-carousel[data-indicator='false'] .charcoal-carousel__scroller {
|
|
242
|
+
scroll-marker-group: none;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.charcoal-carousel__item::scroll-marker {
|
|
246
|
+
content: '';
|
|
247
|
+
width: 8px;
|
|
248
|
+
height: 8px;
|
|
249
|
+
border: 0;
|
|
250
|
+
border-radius: 50%;
|
|
251
|
+
background-color: var(--charcoal-color-text-tertiary-default);
|
|
252
|
+
cursor: pointer;
|
|
253
|
+
transition: 0.2s background-color;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.charcoal-carousel__item::scroll-marker:hover {
|
|
257
|
+
background-color: var(--charcoal-color-text-secondary-default);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.charcoal-carousel__item::scroll-marker:focus {
|
|
261
|
+
outline: 2px solid rgba(0, 150, 250, 0.56);
|
|
262
|
+
outline-offset: 2px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.charcoal-carousel__item::scroll-marker:target-current {
|
|
266
|
+
background-color: var(--charcoal-color-text-default);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.charcoal-carousel__indicator {
|
|
270
|
+
display: none;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/* stylelint-enable property-no-unknown, selector-pseudo-element-no-unknown, selector-pseudo-class-no-unknown */
|
|
274
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { createCarouselStore } from './carouselStore'
|
|
3
|
+
|
|
4
|
+
describe('createCarouselStore', () => {
|
|
5
|
+
it('初期値', () => {
|
|
6
|
+
expect(createCarouselStore().getSnapshot()).toEqual({
|
|
7
|
+
activeIndex: 0,
|
|
8
|
+
canPrev: false,
|
|
9
|
+
canNext: false,
|
|
10
|
+
scroll: null,
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('setActive: 変化なしなら同一参照', () => {
|
|
15
|
+
const s = createCarouselStore()
|
|
16
|
+
const a = s.getSnapshot()
|
|
17
|
+
s.dispatch({ type: 'setActive', index: 0 })
|
|
18
|
+
expect(s.getSnapshot()).toBe(a)
|
|
19
|
+
s.dispatch({ type: 'setActive', index: 2 })
|
|
20
|
+
expect(s.getSnapshot().activeIndex).toBe(2)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('setScrollState: 変化なしなら同一参照', () => {
|
|
24
|
+
const s = createCarouselStore()
|
|
25
|
+
s.dispatch({ type: 'setScrollState', canPrev: true, canNext: true })
|
|
26
|
+
const a = s.getSnapshot()
|
|
27
|
+
s.dispatch({ type: 'setScrollState', canPrev: true, canNext: true })
|
|
28
|
+
expect(s.getSnapshot()).toBe(a)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('requestScroll: index と単調増加 nonce', () => {
|
|
32
|
+
const s = createCarouselStore()
|
|
33
|
+
s.dispatch({ type: 'requestScroll', index: 3 })
|
|
34
|
+
expect(s.getSnapshot().scroll).toEqual({ index: 3, nonce: 1 })
|
|
35
|
+
s.dispatch({ type: 'requestScroll', index: 3 })
|
|
36
|
+
expect(s.getSnapshot().scroll).toEqual({ index: 3, nonce: 2 })
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createStore, type Store } from './store'
|
|
2
|
+
|
|
3
|
+
export type CarouselState = Readonly<{
|
|
4
|
+
activeIndex: number
|
|
5
|
+
canPrev: boolean
|
|
6
|
+
canNext: boolean
|
|
7
|
+
scroll: { index: number; nonce: number } | null
|
|
8
|
+
}>
|
|
9
|
+
|
|
10
|
+
export type CarouselAction =
|
|
11
|
+
| { type: 'setActive'; index: number }
|
|
12
|
+
| { type: 'setScrollState'; canPrev: boolean; canNext: boolean }
|
|
13
|
+
| { type: 'requestScroll'; index: number }
|
|
14
|
+
|
|
15
|
+
export type CarouselStore = Store<CarouselState, CarouselAction>
|
|
16
|
+
|
|
17
|
+
export const INITIAL_CAROUSEL_STATE: CarouselState = {
|
|
18
|
+
activeIndex: 0,
|
|
19
|
+
canPrev: false,
|
|
20
|
+
canNext: false,
|
|
21
|
+
scroll: null,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const reducer = (
|
|
25
|
+
state: CarouselState,
|
|
26
|
+
action: CarouselAction,
|
|
27
|
+
): CarouselState => {
|
|
28
|
+
switch (action.type) {
|
|
29
|
+
case 'setActive':
|
|
30
|
+
return state.activeIndex === action.index
|
|
31
|
+
? state
|
|
32
|
+
: { ...state, activeIndex: action.index }
|
|
33
|
+
case 'setScrollState':
|
|
34
|
+
return state.canPrev === action.canPrev &&
|
|
35
|
+
state.canNext === action.canNext
|
|
36
|
+
? state
|
|
37
|
+
: { ...state, canPrev: action.canPrev, canNext: action.canNext }
|
|
38
|
+
case 'requestScroll':
|
|
39
|
+
return {
|
|
40
|
+
...state,
|
|
41
|
+
scroll: { index: action.index, nonce: (state.scroll?.nonce ?? 0) + 1 },
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function createCarouselStore(): CarouselStore {
|
|
47
|
+
return createStore(reducer, INITIAL_CAROUSEL_STATE)
|
|
48
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
.charcoal-carousel {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: block;
|
|
4
|
+
|
|
5
|
+
&[data-full-width='true'] {
|
|
6
|
+
width: 100vw;
|
|
7
|
+
margin-inline: calc(50% - 50vw);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.charcoal-carousel__viewport {
|
|
12
|
+
position: relative;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.charcoal-carousel__scroller {
|
|
16
|
+
position: relative;
|
|
17
|
+
display: flex;
|
|
18
|
+
gap: 24px;
|
|
19
|
+
overflow-x: auto;
|
|
20
|
+
overflow-y: hidden;
|
|
21
|
+
overscroll-behavior-x: contain;
|
|
22
|
+
scroll-behavior: smooth;
|
|
23
|
+
scrollbar-width: none;
|
|
24
|
+
outline: none;
|
|
25
|
+
|
|
26
|
+
&::-webkit-scrollbar {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&[data-focus-visible] {
|
|
31
|
+
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.charcoal-carousel[data-size='S'] .charcoal-carousel__scroller {
|
|
36
|
+
gap: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* スクロールスナップ type は prop(scrollSnap.type)で scroller に出し分ける。
|
|
40
|
+
align は基底 .charcoal-carousel__item の後(後述)に置く(no-descending-specificity 回避)。
|
|
41
|
+
未指定時の既定(M=none / S=mandatory / align=center)は JS 側で data 属性に解決する。 */
|
|
42
|
+
.charcoal-carousel[data-scroll-snap-type='none'] .charcoal-carousel__scroller {
|
|
43
|
+
scroll-snap-type: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.charcoal-carousel[data-scroll-snap-type='proximity']
|
|
47
|
+
.charcoal-carousel__scroller {
|
|
48
|
+
scroll-snap-type: x proximity;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.charcoal-carousel[data-scroll-snap-type='mandatory']
|
|
52
|
+
.charcoal-carousel__scroller {
|
|
53
|
+
scroll-snap-type: x mandatory;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* グラデーション: はみ出してスクロール可能な側のみ、端のアイテムを背景色(白)へ
|
|
57
|
+
フェードさせる。mask による透過ではなく、72px の「背景色→透明」オーバーレイを
|
|
58
|
+
ビューポートに重ねて白で覆う。スクロール可能な側だけ data-can-prev/next で出し分ける。 */
|
|
59
|
+
.charcoal-carousel[data-has-gradient='true']
|
|
60
|
+
.charcoal-carousel__viewport::before,
|
|
61
|
+
.charcoal-carousel[data-has-gradient='true']
|
|
62
|
+
.charcoal-carousel__viewport::after {
|
|
63
|
+
content: '';
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: 0;
|
|
66
|
+
bottom: 0;
|
|
67
|
+
width: 72px;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
opacity: 0;
|
|
70
|
+
transition: 0.2s opacity;
|
|
71
|
+
z-index: 1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.charcoal-carousel[data-has-gradient='true']
|
|
75
|
+
.charcoal-carousel__viewport::before {
|
|
76
|
+
left: 0;
|
|
77
|
+
background: linear-gradient(to right, #fff, transparent);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.charcoal-carousel[data-has-gradient='true']
|
|
81
|
+
.charcoal-carousel__viewport::after {
|
|
82
|
+
right: 0;
|
|
83
|
+
background: linear-gradient(to left, #fff, transparent);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.charcoal-carousel[data-has-gradient='true'][data-can-prev='true']
|
|
87
|
+
.charcoal-carousel__viewport::before {
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.charcoal-carousel[data-has-gradient='true'][data-can-next='true']
|
|
92
|
+
.charcoal-carousel__viewport::after {
|
|
93
|
+
opacity: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.charcoal-carousel__item {
|
|
97
|
+
flex: 0 0 auto;
|
|
98
|
+
min-width: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.charcoal-carousel[data-size='S'] .charcoal-carousel__item {
|
|
102
|
+
flex: 0 0 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* scroll-snap-align は prop(scrollSnap.align)で出し分ける。基底 .charcoal-carousel__item
|
|
106
|
+
より後に置くことで no-descending-specificity を回避する。 */
|
|
107
|
+
.charcoal-carousel[data-scroll-snap-align='center'] .charcoal-carousel__item {
|
|
108
|
+
scroll-snap-align: center;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.charcoal-carousel[data-scroll-snap-align='start'] .charcoal-carousel__item {
|
|
112
|
+
scroll-snap-align: start;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* ── Navigation Buttons (charcoal IconButton, variant=Overlay size=S) ── */
|
|
116
|
+
|
|
117
|
+
/* マスクと同じ 72px 1fr 72px グリッド。各ボタンは 72px ゾーンの中央に置く。 */
|
|
118
|
+
.charcoal-carousel__navigation {
|
|
119
|
+
position: absolute;
|
|
120
|
+
inset: 0;
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
display: grid;
|
|
123
|
+
grid-template-columns: 72px 1fr 72px;
|
|
124
|
+
align-items: center;
|
|
125
|
+
/* 白フェード(z-index: 1)より上にボタンを表示する */
|
|
126
|
+
z-index: 2;
|
|
127
|
+
/* sandbox 同様、通常は隠してカルーセル hover 時にフェードイン表示する。 */
|
|
128
|
+
opacity: 0;
|
|
129
|
+
transition: 0.4s opacity;
|
|
130
|
+
|
|
131
|
+
&[data-visible='false'] {
|
|
132
|
+
display: none;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* hover で表示。キーボード操作でも到達できるよう focus-within でも表示する。 */
|
|
137
|
+
.charcoal-carousel:hover .charcoal-carousel__navigation,
|
|
138
|
+
.charcoal-carousel:focus-within .charcoal-carousel__navigation {
|
|
139
|
+
opacity: 1;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.charcoal-carousel__navigation__item {
|
|
143
|
+
pointer-events: auto;
|
|
144
|
+
|
|
145
|
+
&[data-direction='prev'] {
|
|
146
|
+
grid-column: 1;
|
|
147
|
+
justify-self: center;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&[data-direction='next'] {
|
|
151
|
+
grid-column: 3;
|
|
152
|
+
justify-self: center;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* スクロール端では非表示。IconButton の disabled スタイル(opacity:0.32)より
|
|
157
|
+
高い詳細度で打ち消すため、ルートを前置する。 */
|
|
158
|
+
.charcoal-carousel .charcoal-carousel__navigation__item[data-hidden='true'] {
|
|
159
|
+
opacity: 0;
|
|
160
|
+
pointer-events: none;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* タッチデバイスではナビゲーションボタンを出さず、スワイプ操作に委ねる。 */
|
|
164
|
+
@media (hover: none) and (pointer: coarse) {
|
|
165
|
+
.charcoal-carousel__navigation {
|
|
166
|
+
display: none;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* ── Indicator: JS Fallback ── */
|
|
171
|
+
|
|
172
|
+
.charcoal-carousel__indicator {
|
|
173
|
+
display: flex;
|
|
174
|
+
justify-content: center;
|
|
175
|
+
align-items: center;
|
|
176
|
+
height: 40px;
|
|
177
|
+
gap: 8px;
|
|
178
|
+
|
|
179
|
+
&[data-visible='false'] {
|
|
180
|
+
display: none;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.charcoal-carousel__indicator__item {
|
|
185
|
+
appearance: none;
|
|
186
|
+
box-sizing: border-box;
|
|
187
|
+
width: 8px;
|
|
188
|
+
height: 8px;
|
|
189
|
+
padding: 0;
|
|
190
|
+
border: 0;
|
|
191
|
+
border-radius: 50%;
|
|
192
|
+
background-color: var(--charcoal-color-text-tertiary-default);
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
transition: 0.2s background-color;
|
|
195
|
+
|
|
196
|
+
&:hover {
|
|
197
|
+
background-color: var(--charcoal-color-text-secondary-default);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
&:focus-visible {
|
|
201
|
+
outline: 2px solid rgba(0, 150, 250, 0.56);
|
|
202
|
+
outline-offset: 2px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&[data-active='true'] {
|
|
206
|
+
background-color: var(--charcoal-color-text-default);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* ── CSS Scroll Markers (progressive enhancement) ── */
|
|
211
|
+
|
|
212
|
+
/* CSS Scroll Markers / Anchor Positioning は新しい仕様で、stylelint がプロパティ・
|
|
213
|
+
擬似要素・擬似クラスを未知と判定するため、この @supports ブロックでは該当ルールを無効化する。 */
|
|
214
|
+
/* stylelint-disable property-no-unknown, selector-pseudo-element-no-unknown, selector-pseudo-class-no-unknown */
|
|
215
|
+
@supports (scroll-marker-group: after) {
|
|
216
|
+
.charcoal-carousel[data-indicator='true'] {
|
|
217
|
+
padding-bottom: 40px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.charcoal-carousel__scroller {
|
|
221
|
+
anchor-name: --charcoal-carousel;
|
|
222
|
+
scroll-marker-group: after;
|
|
223
|
+
|
|
224
|
+
&::scroll-button(*) {
|
|
225
|
+
content: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
&::scroll-marker-group {
|
|
229
|
+
display: flex;
|
|
230
|
+
justify-content: center;
|
|
231
|
+
align-items: center;
|
|
232
|
+
height: 40px;
|
|
233
|
+
gap: 8px;
|
|
234
|
+
|
|
235
|
+
position: absolute;
|
|
236
|
+
position-anchor: --charcoal-carousel;
|
|
237
|
+
top: anchor(bottom);
|
|
238
|
+
justify-self: anchor-center;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.charcoal-carousel[data-indicator='false'] .charcoal-carousel__scroller {
|
|
243
|
+
scroll-marker-group: none;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.charcoal-carousel__item::scroll-marker {
|
|
247
|
+
content: '';
|
|
248
|
+
width: 8px;
|
|
249
|
+
height: 8px;
|
|
250
|
+
border: 0;
|
|
251
|
+
border-radius: 50%;
|
|
252
|
+
background-color: var(--charcoal-color-text-tertiary-default);
|
|
253
|
+
cursor: pointer;
|
|
254
|
+
transition: 0.2s background-color;
|
|
255
|
+
|
|
256
|
+
&:hover {
|
|
257
|
+
background-color: var(--charcoal-color-text-secondary-default);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&:focus {
|
|
261
|
+
outline: 2px solid rgba(0, 150, 250, 0.56);
|
|
262
|
+
outline-offset: 2px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&:target-current {
|
|
266
|
+
background-color: var(--charcoal-color-text-default);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.charcoal-carousel__indicator {
|
|
271
|
+
display: none;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/* stylelint-enable property-no-unknown, selector-pseudo-element-no-unknown, selector-pseudo-class-no-unknown */
|