@yamatozhen/design_system 1.0.1 → 1.2.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.
- package/LICENSE +201 -201
- package/README.md +101 -101
- package/package.json +50 -50
- package/scripts/postinstall.js +91 -91
- package/template/app/ClientNav.tsx +258 -310
- package/template/app/globals.css +2 -167
- package/template/app/layout.tsx +94 -82
- package/template/app/themes/dark-mc.css +51 -51
- package/template/app/themes/dark.css +51 -51
- package/template/app/themes/light-mc.css +51 -51
- package/template/app/themes/light.css +51 -51
- package/template/app/themes/theme.css +272 -82
- package/template/components/{layout/button → (buttons)}/Button.module.css +351 -305
- package/template/components/{layout/button → (buttons)}/ButtonGroup.tsx +414 -503
- package/template/components/{layout/button → (buttons)}/FAB.tsx +119 -118
- package/template/components/(buttons)/button.tsx +164 -0
- package/template/components/(controls)/slider/Slider.module.css +250 -0
- package/template/components/(controls)/slider/Slider.tsx +386 -0
- package/template/components/{layout → (controls)}/switch/Switch.module.css +108 -102
- package/template/components/{layout → (controls)}/switch/Switch.tsx +69 -48
- package/template/components/(date & time)/calendar/Calendar.module.css +125 -0
- package/template/components/(date & time)/calendar/Calendar.tsx +206 -0
- package/template/components/(date & time)/dateField/DateField.module.css +25 -0
- package/template/components/(date & time)/dateField/DateField.tsx +193 -0
- package/template/components/(date & time)/datePicker/DatePicker.tsx +118 -0
- package/template/components/(date & time)/dateRangePicker/DateRangePicker.tsx +144 -0
- package/template/components/(date & time)/rangeCalendar/RangeCalendar.module.css +203 -0
- package/template/components/(date & time)/rangeCalendar/RangeCalendar.tsx +263 -0
- package/template/components/(date & time)/shared/dateUtils.ts +107 -0
- package/template/components/(date & time)/timeField/TimeField.module.css +39 -0
- package/template/components/(date & time)/timeField/TimeField.tsx +158 -0
- package/template/components/(feedback)/circularProgress/CircularProgress.tsx +646 -0
- package/template/components/(feedback)/linearProgress/LinearProgress.tsx +337 -0
- package/template/components/(feedback)/meter/Meter.tsx +111 -0
- package/template/components/(feedback)/skeleton/Skeleton.module.css +49 -0
- package/template/components/(feedback)/skeleton/Skeleton.tsx +32 -0
- package/template/components/(feedback)/spinner/Spinner.module.css +27 -0
- package/template/components/(feedback)/spinner/Spinner.tsx +60 -0
- package/template/components/(forms)/checkbox/Checkbox.tsx +121 -0
- package/template/components/(forms)/checkboxGroup/CheckboxGroup.tsx +83 -0
- package/template/components/(forms)/description/Description.tsx +34 -0
- package/template/components/(forms)/errorMessage/ErrorMessage.tsx +31 -0
- package/template/components/(forms)/fieldError/FieldError.tsx +39 -0
- package/template/components/(forms)/fieldset/Fieldset.tsx +51 -0
- package/template/components/(forms)/form/Form.tsx +54 -0
- package/template/components/(forms)/input/Input.tsx +50 -0
- package/template/components/(forms)/inputGroup/InputGroup.tsx +65 -0
- package/template/components/(forms)/inputOtp/InputOtp.tsx +139 -0
- package/template/components/(forms)/label/Label.tsx +46 -0
- package/template/components/(forms)/numberField/NumberField.tsx +292 -0
- package/template/components/(forms)/radioGroup/RadioGroup.tsx +175 -0
- package/template/components/(forms)/searchField/SearchField.tsx +139 -0
- package/template/components/(forms)/shared/field.module.css +75 -0
- package/template/components/(forms)/shared/fieldContext.ts +28 -0
- package/template/components/(forms)/textArea/TextArea.tsx +55 -0
- package/template/components/(forms)/textField/TextField.tsx +91 -0
- package/template/components/{layout → (layout)}/Lightbox/LightboxCard.tsx +100 -100
- package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.module.css +249 -249
- package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.tsx +72 -72
- package/template/components/{layout → (layout)}/Lightbox/LightboxGrid.tsx +185 -186
- package/template/components/{layout → (layout)}/Lightbox/LightboxModal.module.css +395 -395
- package/template/components/{layout → (layout)}/Lightbox/LightboxModal.tsx +498 -500
- package/template/components/{layout → (layout)}/Lightbox/demo.tsx +396 -412
- package/template/components/{layout → (layout)}/Lightbox/index.ts +30 -30
- package/template/components/{layout → (layout)}/Lightbox/types.ts +101 -113
- package/template/components/{layout → (layout)}/Lightbox/useLightboxFilters.ts +140 -140
- package/template/components/(layout)/accordion/Accordion.module.css +108 -0
- package/template/components/(layout)/accordion/Accordion.tsx +251 -0
- package/template/components/(layout)/card/Card.module.css +136 -0
- package/template/components/(layout)/card/Card.tsx +371 -0
- package/template/components/(layout)/list/List.module.css +83 -0
- package/template/components/(layout)/list/List.tsx +332 -0
- package/template/components/{layout → (layout)}/navigation/Wrap.tsx +41 -41
- package/template/components/(layout)/navigation/breadcrumbs/Breadcrumbs.tsx +145 -0
- package/template/components/{layout/navigation/nav/Nav.module.css → (layout)/navigation/nav/Nav.module.css.old} +474 -508
- package/template/components/{layout → (layout)}/navigation/nav/Nav.tsx +186 -167
- package/template/components/{layout → (layout)}/navigation/nav/NavBar.tsx +396 -419
- package/template/components/{layout → (layout)}/navigation/nav/NavContext.tsx +259 -259
- package/template/components/{layout → (layout)}/navigation/nav/NavItem.tsx +195 -173
- package/template/components/{layout → (layout)}/navigation/nav/NavNew.module.css +406 -373
- package/template/components/{layout → (layout)}/navigation/nav/NavRail.tsx +317 -315
- package/template/components/{layout → (layout)}/navigation/nav/NavSection.tsx +101 -102
- package/template/components/{layout → (layout)}/navigation/nav/NavTab.tsx +25 -25
- package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.module.css +253 -252
- package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.tsx +448 -399
- package/template/components/{layout → (layout)}/navigation/nav/navftb/useTabIndicator.ts +498 -484
- package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.module.css +59 -59
- package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.tsx +465 -473
- package/template/components/(layout)/navigation/pagination/Pagination.tsx +261 -0
- package/template/components/{layout → (layout)}/pages/loadingScreen.tsx +117 -102
- package/template/components/{layout → (layout)}/pages/maintenance/Maintenance.tsx +52 -52
- package/template/components/{layout → (layout)}/pages/maintenance/maintenance.module.css +162 -162
- package/template/components/(layout)/scrollShadow/ScrollShadow.module.css +81 -0
- package/template/components/(layout)/scrollShadow/ScrollShadow.tsx +161 -0
- package/template/components/(layout)/scrollShadow/useScrollShadow.ts +130 -0
- package/template/components/(layout)/separator/Separator.tsx +112 -0
- package/template/components/(overlays)/accessibilityModal/AccessibilityModal.tsx +307 -0
- package/template/components/(overlays)/drawer/Drawer.tsx +953 -0
- package/template/components/(overlays)/modal/Modal.tsx +654 -0
- package/template/components/(overlays)/popover/Popover.tsx +420 -0
- package/template/components/(overlays)/toast/Toast.tsx +692 -0
- package/template/components/(pickers)/autocomplete/Autocomplete.tsx +24 -0
- package/template/components/(pickers)/comboBox/ComboBox.tsx +21 -0
- package/template/components/(pickers)/select/Select.tsx +188 -0
- package/template/components/(pickers)/shared/FilterableField.tsx +223 -0
- package/template/components/(pickers)/shared/PickerItem.ts +13 -0
- package/template/components/tools/CustomScrollbar.tsx +107 -0
- package/template/components/tools/Divider.tsx +11 -11
- package/template/components/tools/ReduceMotionContext.tsx +5 -5
- package/template/components/tools/Sinewave.tsx +396 -199
- package/template/components/tools/SinewaveProgress.tsx +140 -135
- package/template/components/tools/badge/Badge.tsx +28 -28
- package/template/components/tools/dropdown/drop.module.css +196 -0
- package/template/components/tools/dropdown/drop.tsx +568 -0
- package/template/components/tools/easing.ts +118 -0
- package/template/components/tools/flubber.d.ts +6 -6
- package/template/components/tools/footer/Footer.tsx +20 -0
- package/template/components/tools/input/Input.module.css +45 -0
- package/template/components/tools/input/Input.tsx +99 -0
- package/template/components/tools/label/Icon.tsx +39 -0
- package/template/components/tools/label/Label.tsx +156 -0
- package/template/components/tools/mobileViewProvider.tsx +53 -58
- package/template/components/tools/ripple/ripple.css +38 -41
- package/template/components/tools/ripple/ripple.tsx +78 -53
- package/template/components/tools/shape/Shape.module.css +25 -0
- package/template/components/tools/shape/{ShapeMorph.tsx → Shape.tsx} +316 -190
- package/template/components/tools/shape/ShapeLoader.tsx +104 -101
- package/template/components/tools/shape/ShapePaths.ts +116 -116
- package/template/components/tools/switch/Switch.module.css +102 -102
- package/template/components/tools/switch/Switch.tsx +48 -48
- package/template/components/tools/useBodyScrollLock.tsx +27 -27
- package/template/components/tools/useImageColor.ts +47 -47
- package/template/components/tools/useNavSheetDrag.tsx +196 -196
- package/template/components/layout/accordion/Accordion.module.css +0 -149
- package/template/components/layout/accordion/Accordion.tsx +0 -114
- package/template/components/layout/button/button.tsx +0 -128
- package/template/components/layout/button/drop.module.css +0 -229
- package/template/components/layout/button/drop.tsx +0 -516
- package/template/components/layout/hero/v1/heroSlideshow.module.css +0 -107
- package/template/components/layout/hero/v1/heroSlideshow.tsx +0 -233
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +0 -126
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +0 -290
- package/template/components/layout/modals/alert/Alert.tsx +0 -188
- package/template/components/layout/navigation/MioCard.module.css +0 -88
- package/template/components/layout/navigation/MioCard.tsx +0 -266
- package/template/components/tools/ProgressiveBlur.tsx +0 -73
- package/template/components/tools/icon/icon.module.css +0 -0
- package/template/components/tools/icon/icon.tsx +0 -125
- package/template/components/tools/react-bits/ClickSpark.tsx +0 -177
- package/template/components/tools/react-bits/FadeContent.tsx +0 -90
- package/template/components/tools/react-bits/GlareHover.tsx +0 -73
- package/template/components/tools/react-bits/GradientText/GradientText.css +0 -70
- package/template/components/tools/react-bits/GradientText/GradientText.tsx +0 -44
- package/template/components/tools/react-bits/Magnet.tsx +0 -118
- package/template/components/tools/react-bits/Stepper/Stepper.css +0 -134
- package/template/components/tools/react-bits/Stepper/Stepper.tsx +0 -412
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, {
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
11
|
+
import Image from "next/image";
|
|
12
|
+
import Ripple, { RippleHandle } from "@/components/tools/ripple/ripple";
|
|
13
|
+
import Icon from "@/components/tools/label/Icon";
|
|
14
|
+
import Label from "@/components/tools/label/Label";
|
|
15
|
+
import Shape from "@/components/tools/shape/Shape";
|
|
16
|
+
import type { ShapeInput } from "@/components/tools/shape/ShapePaths";
|
|
17
|
+
import { useBreakpoints } from "@/components/tools/mobileViewProvider";
|
|
18
|
+
import styles from "./Card.module.css";
|
|
19
|
+
|
|
20
|
+
export type CardVariant =
|
|
21
|
+
| "highest"
|
|
22
|
+
| "high"
|
|
23
|
+
| "surface"
|
|
24
|
+
| "low"
|
|
25
|
+
| "lowest"
|
|
26
|
+
| "primary"
|
|
27
|
+
| "secondary"
|
|
28
|
+
| "tertiary";
|
|
29
|
+
|
|
30
|
+
const COLOR_ROLE_VARIANTS = new Set<CardVariant>([
|
|
31
|
+
"primary",
|
|
32
|
+
"secondary",
|
|
33
|
+
"tertiary",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
function isColorRole(variant: CardVariant) {
|
|
37
|
+
return COLOR_ROLE_VARIANTS.has(variant);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type CardProps = {
|
|
41
|
+
variant?: CardVariant;
|
|
42
|
+
onClick?: () => void;
|
|
43
|
+
navigate?: "next" | "previous" | false;
|
|
44
|
+
comment?: string;
|
|
45
|
+
elevated?: boolean;
|
|
46
|
+
withIcon?: { systemName: string; shapePath: ShapeInput };
|
|
47
|
+
withImage?: { src: string; alt: string };
|
|
48
|
+
style?: React.CSSProperties;
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const CardContext = createContext<{ variant: CardVariant }>({
|
|
53
|
+
variant: "surface",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function Card({
|
|
57
|
+
variant = "surface",
|
|
58
|
+
onClick,
|
|
59
|
+
navigate = false,
|
|
60
|
+
comment,
|
|
61
|
+
elevated = false,
|
|
62
|
+
withIcon,
|
|
63
|
+
withImage,
|
|
64
|
+
style,
|
|
65
|
+
children,
|
|
66
|
+
}: CardProps) {
|
|
67
|
+
const rippleRef = useRef<RippleHandle>(null);
|
|
68
|
+
const { isMobile } = useBreakpoints();
|
|
69
|
+
const interactive = Boolean(onClick);
|
|
70
|
+
|
|
71
|
+
// Border-radius, background-color, and the ripple are all pure-CSS hover
|
|
72
|
+
// effects gated behind .interactive — Shape's morph trigger can't be,
|
|
73
|
+
// since it's a React prop (isHovered), not something CSS can drive. This
|
|
74
|
+
// is the one piece of JS-tracked hover state Card needs, and only for
|
|
75
|
+
// that — same "only when onClick is set" gating as everything else.
|
|
76
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
77
|
+
const handleMouseEnter = useCallback(() => {
|
|
78
|
+
if (interactive) setIsHovering(true);
|
|
79
|
+
}, [interactive]);
|
|
80
|
+
const handleMouseLeave = useCallback(() => {
|
|
81
|
+
if (interactive) setIsHovering(false);
|
|
82
|
+
}, [interactive]);
|
|
83
|
+
|
|
84
|
+
const handleClick = useCallback(
|
|
85
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
86
|
+
if (!interactive) return;
|
|
87
|
+
rippleRef.current?.triggerRipple(e);
|
|
88
|
+
onClick?.();
|
|
89
|
+
},
|
|
90
|
+
[interactive, onClick],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Idle background resolution:
|
|
94
|
+
// - primary/secondary/tertiary: static {variant}-container, set inline so
|
|
95
|
+
// it always wins over the CSS :hover rule (no hover swap).
|
|
96
|
+
// - non-interactive surface/elevation: static resolveSurfaceVar-style token,
|
|
97
|
+
// also inline (no hover to speak of, nothing clickable).
|
|
98
|
+
// - interactive surface/elevation: idle color goes through the
|
|
99
|
+
// --card-idle-bg custom property instead of `backgroundColor` directly,
|
|
100
|
+
// so the CSS `.interactive:hover` rule (secondary-container) can still
|
|
101
|
+
// win on top of it — an inline `backgroundColor` would block that.
|
|
102
|
+
const bodyStyle = useMemo<React.CSSProperties>(() => {
|
|
103
|
+
const base: React.CSSProperties = {
|
|
104
|
+
width: "100%",
|
|
105
|
+
...style,
|
|
106
|
+
border: undefined,
|
|
107
|
+
// The inset outline itself now lives on .cardBody::before (see
|
|
108
|
+
// Card.module.css) so it paints on top of a bled-through image
|
|
109
|
+
// instead of behind it. This only carries elevated's outer layers,
|
|
110
|
+
// which must stay on cardBody itself — on a child/pseudo-element
|
|
111
|
+
// they'd get clipped by cardBody's own overflow: hidden.
|
|
112
|
+
boxShadow: elevated
|
|
113
|
+
? "inset 0 0 0 1px var(--globalUIBorderCard), 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.1)"
|
|
114
|
+
: "inset 0 0 0 1px var(--globalUIBorderCard)",
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
if (isColorRole(variant)) {
|
|
118
|
+
base.backgroundColor = `var(--md-sys-color-${variant}-container)`;
|
|
119
|
+
return base;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!interactive) {
|
|
123
|
+
base.backgroundColor =
|
|
124
|
+
variant === "surface"
|
|
125
|
+
? "var(--md-sys-color-surface-container)"
|
|
126
|
+
: `var(--md-sys-color-surface-container-${variant})`;
|
|
127
|
+
return base;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const idleVar =
|
|
131
|
+
variant === "surface"
|
|
132
|
+
? isMobile
|
|
133
|
+
? "var(--md-sys-color-surface-container-low)"
|
|
134
|
+
: "var(--md-sys-color-surface-container-lowest)"
|
|
135
|
+
: `var(--md-sys-color-surface-container-${variant})`;
|
|
136
|
+
(base as React.CSSProperties & Record<string, string>)["--card-idle-bg"] =
|
|
137
|
+
idleVar;
|
|
138
|
+
return base;
|
|
139
|
+
}, [style, elevated, variant, interactive, isMobile]);
|
|
140
|
+
|
|
141
|
+
// Navigate label color: static per variant, no hover dependence.
|
|
142
|
+
const navigateColor = isColorRole(variant)
|
|
143
|
+
? `color-mix(in srgb, var(--md-sys-color-on-${variant}-container) 50%, transparent)`
|
|
144
|
+
: "var(--md-sys-color-outline)";
|
|
145
|
+
|
|
146
|
+
// withIcon's Shape colors — hover-reactive, driven by the same
|
|
147
|
+
// interactive+isHovering signal that triggers Shape's morph:
|
|
148
|
+
// - primary/secondary/tertiary: idle {variant}-container/on-{variant}-container,
|
|
149
|
+
// hover swaps to the bold {variant}/on-{variant} pair.
|
|
150
|
+
// - surface/low/high/lowest/highest: idle is always surface-container-lowest
|
|
151
|
+
// (not per-variant), hover swaps to primary/on-primary.
|
|
152
|
+
const shapeIsHovered = interactive && isHovering;
|
|
153
|
+
const shapeBackground = isColorRole(variant)
|
|
154
|
+
? shapeIsHovered
|
|
155
|
+
? `var(--md-sys-color-${variant})`
|
|
156
|
+
: `var(--md-sys-color-surface-container-lowest)`
|
|
157
|
+
: shapeIsHovered
|
|
158
|
+
? "var(--md-sys-color-primary)"
|
|
159
|
+
: "var(--globalUIBorderCard)";
|
|
160
|
+
const shapeColor = isColorRole(variant)
|
|
161
|
+
? shapeIsHovered
|
|
162
|
+
? `var(--md-sys-color-on-${variant})`
|
|
163
|
+
: `var(--md-sys-color-on-surface-container)`
|
|
164
|
+
: shapeIsHovered
|
|
165
|
+
? "var(--md-sys-color-on-primary)"
|
|
166
|
+
: "var(--md-sys-color-on-surface)";
|
|
167
|
+
|
|
168
|
+
const contextValue = useMemo(() => ({ variant }), [variant]);
|
|
169
|
+
|
|
170
|
+
// Renders the navigate label. `extraStyle` carries the negative-margin
|
|
171
|
+
// tuck-in used only when it's placed standalone (no Header to live in) —
|
|
172
|
+
// it doesn't make sense once it's a flex sibling inside Header instead.
|
|
173
|
+
const renderNavigate = (extraStyle?: React.CSSProperties) => {
|
|
174
|
+
if (!navigate) return null;
|
|
175
|
+
return (
|
|
176
|
+
<span
|
|
177
|
+
style={{
|
|
178
|
+
...extraStyle,
|
|
179
|
+
display: "flex",
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
gap: 4,
|
|
182
|
+
fontWeight: 400,
|
|
183
|
+
color: navigateColor,
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
{navigate === "next" ? (
|
|
187
|
+
<>
|
|
188
|
+
<p>Up next</p>
|
|
189
|
+
<Icon systemName="arrow_right_alt" />
|
|
190
|
+
</>
|
|
191
|
+
) : (
|
|
192
|
+
<>
|
|
193
|
+
<Icon systemName="arrow_left_alt" />
|
|
194
|
+
<Label label="Previous" />
|
|
195
|
+
</>
|
|
196
|
+
)}
|
|
197
|
+
</span>
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// If navigate is set, it always ends up inside a Card.Header — the
|
|
202
|
+
// existing one if there is one (injected as its first child), or a
|
|
203
|
+
// synthesized Header holding just the navigate label if there isn't.
|
|
204
|
+
const childArray = React.Children.toArray(children);
|
|
205
|
+
const headerIndex = childArray.findIndex(
|
|
206
|
+
(child) => React.isValidElement(child) && child.type === CardHeader,
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
let bodyChildren: React.ReactNode = childArray;
|
|
210
|
+
if (navigate) {
|
|
211
|
+
if (headerIndex !== -1) {
|
|
212
|
+
bodyChildren = childArray.map((child, i) => {
|
|
213
|
+
if (i !== headerIndex) return child;
|
|
214
|
+
const headerChild = child as React.ReactElement<CardSectionProps>;
|
|
215
|
+
return React.cloneElement(headerChild, {
|
|
216
|
+
children: (
|
|
217
|
+
<>
|
|
218
|
+
{renderNavigate()}
|
|
219
|
+
{headerChild.props.children}
|
|
220
|
+
</>
|
|
221
|
+
),
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
} else {
|
|
225
|
+
bodyChildren = (
|
|
226
|
+
<>
|
|
227
|
+
<CardHeader>{renderNavigate()}</CardHeader>
|
|
228
|
+
{childArray}
|
|
229
|
+
</>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<div onClick={handleClick} style={{ width: "100%", ...style }}>
|
|
236
|
+
<div
|
|
237
|
+
className={`${styles.cardBody} ${interactive ? styles.interactive : ""}`}
|
|
238
|
+
style={bodyStyle}
|
|
239
|
+
onMouseEnter={handleMouseEnter}
|
|
240
|
+
onMouseLeave={handleMouseLeave}
|
|
241
|
+
>
|
|
242
|
+
{withImage && (
|
|
243
|
+
<Image
|
|
244
|
+
src={withImage.src}
|
|
245
|
+
alt={withImage.alt}
|
|
246
|
+
width={800}
|
|
247
|
+
height={400}
|
|
248
|
+
/>
|
|
249
|
+
)}
|
|
250
|
+
<div className={styles.cardRow}>
|
|
251
|
+
<div className={styles.cardColumn}>
|
|
252
|
+
<CardContext.Provider value={contextValue}>
|
|
253
|
+
{bodyChildren}
|
|
254
|
+
</CardContext.Provider>
|
|
255
|
+
</div>
|
|
256
|
+
{withIcon && (
|
|
257
|
+
<Shape
|
|
258
|
+
systemName={withIcon.systemName}
|
|
259
|
+
shapePath={withIcon.shapePath}
|
|
260
|
+
size="sm"
|
|
261
|
+
background={shapeBackground}
|
|
262
|
+
color={shapeColor}
|
|
263
|
+
isHovered={shapeIsHovered}
|
|
264
|
+
/>
|
|
265
|
+
)}
|
|
266
|
+
</div>
|
|
267
|
+
{interactive && <Ripple ref={rippleRef} />}
|
|
268
|
+
</div>
|
|
269
|
+
{comment && (
|
|
270
|
+
<p
|
|
271
|
+
style={{
|
|
272
|
+
fontSize: 14,
|
|
273
|
+
color: "var(--md-sys-color-outline)",
|
|
274
|
+
padding: "12px 24px",
|
|
275
|
+
}}
|
|
276
|
+
>
|
|
277
|
+
{comment}
|
|
278
|
+
</p>
|
|
279
|
+
)}
|
|
280
|
+
</div>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
type CardSectionProps = {
|
|
285
|
+
children?: React.ReactNode;
|
|
286
|
+
style?: React.CSSProperties;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
function CardHeader({ children, style }: CardSectionProps) {
|
|
290
|
+
const { variant } = useContext(CardContext);
|
|
291
|
+
const colorRole = isColorRole(variant);
|
|
292
|
+
return (
|
|
293
|
+
<div
|
|
294
|
+
className="cardHeader"
|
|
295
|
+
style={{
|
|
296
|
+
display: "flex",
|
|
297
|
+
flexDirection: "column",
|
|
298
|
+
width: "100%",
|
|
299
|
+
justifyContent: "flex-start",
|
|
300
|
+
alignItems: "flex-start",
|
|
301
|
+
color: colorRole
|
|
302
|
+
? `var(--md-sys-color-on-${variant}-container)`
|
|
303
|
+
: "var(--md-sys-color-on-surface)",
|
|
304
|
+
filter: colorRole ? "var(--filterBrightness)" : undefined,
|
|
305
|
+
...style,
|
|
306
|
+
}}
|
|
307
|
+
>
|
|
308
|
+
{children}
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function CardContent({ children, style }: CardSectionProps) {
|
|
314
|
+
const { variant } = useContext(CardContext);
|
|
315
|
+
const colorRole = isColorRole(variant);
|
|
316
|
+
return (
|
|
317
|
+
<div
|
|
318
|
+
className="cardContent"
|
|
319
|
+
style={{
|
|
320
|
+
display: "flex",
|
|
321
|
+
width: "100%",
|
|
322
|
+
alignItems: "flex-start",
|
|
323
|
+
justifyContent: "space-between",
|
|
324
|
+
color: colorRole
|
|
325
|
+
? `var(--md-sys-color-on-${variant}-container)`
|
|
326
|
+
: "var(--md-sys-color-on-surface-variant)",
|
|
327
|
+
...style,
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
{children}
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function CardFooter({ children, style }: CardSectionProps) {
|
|
336
|
+
return (
|
|
337
|
+
<div
|
|
338
|
+
className="cardFooter"
|
|
339
|
+
style={{
|
|
340
|
+
display: "flex",
|
|
341
|
+
width: "calc(100% + 24px)",
|
|
342
|
+
justifyContent: "space-between",
|
|
343
|
+
marginLeft: "auto",
|
|
344
|
+
margin: "10px -12px -12px -12px",
|
|
345
|
+
...style,
|
|
346
|
+
}}
|
|
347
|
+
>
|
|
348
|
+
{children}
|
|
349
|
+
</div>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export default Object.assign(Card, {
|
|
354
|
+
Header: CardHeader,
|
|
355
|
+
Content: CardContent,
|
|
356
|
+
Footer: CardFooter,
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
/* Example usage:
|
|
360
|
+
|
|
361
|
+
<Card variant="primary" navigate="next" onClick={() => {}}>
|
|
362
|
+
<Image src="..." alt="..." />
|
|
363
|
+
<Card.Header>
|
|
364
|
+
<span>Chapter 3</span>
|
|
365
|
+
</Card.Header>
|
|
366
|
+
<Card.Content>
|
|
367
|
+
<span>Body content</span>
|
|
368
|
+
</Card.Content>
|
|
369
|
+
</Card>
|
|
370
|
+
|
|
371
|
+
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.list {
|
|
2
|
+
list-style: none;
|
|
3
|
+
margin: 0;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
border-radius: var(--borderRadius-md);
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
gap: 2px;
|
|
9
|
+
}
|
|
10
|
+
.wrapper {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 12px;
|
|
14
|
+
padding: 12px;
|
|
15
|
+
min-height: 52px;
|
|
16
|
+
transition: background-color var(--transition-expressive-color);
|
|
17
|
+
border-radius: calc(var(--borderRadius-xs) * 0.8);
|
|
18
|
+
filter: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.wrapper:last-child {
|
|
22
|
+
border-radius: calc(var(--borderRadius-xs) * 0.8)
|
|
23
|
+
calc(var(--borderRadius-xs) * 0.8) var(--borderRadius-md)
|
|
24
|
+
var(--borderRadius-md);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.wrapper:first-child {
|
|
28
|
+
border-radius: var(--borderRadius-md) var(--borderRadius-md)
|
|
29
|
+
calc(var(--borderRadius-xs) * 0.8) calc(var(--borderRadius-xs) * 0.8);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.wrapper:only-of-type {
|
|
33
|
+
border-radius: var(--borderRadius-md);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.row {
|
|
37
|
+
gap: 12px;
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
}
|
|
42
|
+
.wrapper[data-clickable] {
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
&:hover {
|
|
45
|
+
filter: var(--brightnessFilter);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.children {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
gap: 12px;
|
|
53
|
+
padding: 14px 0 4px 0;
|
|
54
|
+
margin-inline: 12px;
|
|
55
|
+
border-top: 1px solid var(--globalUIBorderCard);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.rowText,
|
|
59
|
+
.rowTextWithIcon {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
flex: 1 1 auto;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.rowText {
|
|
67
|
+
margin-left: 12px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.rowTitle {
|
|
71
|
+
font-size: var(--font-size-base);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.rowDescription {
|
|
75
|
+
font-size: 0.85em;
|
|
76
|
+
line-height: 1.2;
|
|
77
|
+
margin-top: 2px;
|
|
78
|
+
margin-bottom: 6px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
:global([data-show-borders="true"]) .wrapper {
|
|
82
|
+
box-shadow: var(--a11y-border) !important;
|
|
83
|
+
}
|