@sabrenski/spire-ui 0.0.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 +21 -0
- package/README.md +233 -0
- package/dist/index.d.ts +4981 -0
- package/dist/spire-ui.css +1 -0
- package/dist/spire-ui.es.js +18403 -0
- package/dist/spire-ui.umd.js +45 -0
- package/package.json +83 -0
- package/src/components/Accordion/Accordion.test.ts +218 -0
- package/src/components/Accordion/AccordionContent.vue +112 -0
- package/src/components/Accordion/AccordionItem.vue +87 -0
- package/src/components/Accordion/AccordionRoot.vue +111 -0
- package/src/components/Accordion/AccordionTrigger.vue +125 -0
- package/src/components/Accordion/index.ts +11 -0
- package/src/components/Accordion/keys.ts +23 -0
- package/src/components/Avatar/Avatar.test.ts +181 -0
- package/src/components/Avatar/Avatar.vue +150 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Badge/Badge.test.ts +141 -0
- package/src/components/Badge/Badge.vue +133 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/BadgeContainer/BadgeContainer.test.ts +150 -0
- package/src/components/BadgeContainer/BadgeContainer.vue +90 -0
- package/src/components/BadgeContainer/index.ts +2 -0
- package/src/components/Breadcrumb/Breadcrumb.test.ts +342 -0
- package/src/components/Breadcrumb/BreadcrumbEllipsis.vue +96 -0
- package/src/components/Breadcrumb/BreadcrumbItem.vue +16 -0
- package/src/components/Breadcrumb/BreadcrumbLink.vue +67 -0
- package/src/components/Breadcrumb/BreadcrumbList.vue +20 -0
- package/src/components/Breadcrumb/BreadcrumbPage.vue +25 -0
- package/src/components/Breadcrumb/BreadcrumbRoot.vue +41 -0
- package/src/components/Breadcrumb/BreadcrumbSeparator.vue +63 -0
- package/src/components/Breadcrumb/index.ts +13 -0
- package/src/components/Breadcrumb/keys.ts +7 -0
- package/src/components/Button/Button.test.ts +231 -0
- package/src/components/Button/Button.vue +349 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Callout/Callout.test.ts +260 -0
- package/src/components/Callout/Callout.vue +341 -0
- package/src/components/Callout/index.ts +2 -0
- package/src/components/Card/Card.test.ts +565 -0
- package/src/components/Card/Card.vue +209 -0
- package/src/components/Card/CardContent.vue +57 -0
- package/src/components/Card/CardFooter.vue +72 -0
- package/src/components/Card/CardHeader.vue +111 -0
- package/src/components/Card/CardImage.vue +124 -0
- package/src/components/Card/index.ts +14 -0
- package/src/components/Chart/BarChart.vue +208 -0
- package/src/components/Chart/BaseChart.vue +444 -0
- package/src/components/Chart/Chart.test.ts +359 -0
- package/src/components/Chart/DonutChart.vue +283 -0
- package/src/components/Chart/LineChart.vue +211 -0
- package/src/components/Chart/index.ts +20 -0
- package/src/components/Chart/useChartTheme.ts +192 -0
- package/src/components/Checkbox/Checkbox.test.ts +209 -0
- package/src/components/Checkbox/Checkbox.vue +285 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/ChoiceChip/ChoiceChip.test.ts +142 -0
- package/src/components/ChoiceChip/ChoiceChip.vue +218 -0
- package/src/components/ChoiceChip/index.ts +2 -0
- package/src/components/ChoiceChipGroup/ChoiceChipGroup.test.ts +151 -0
- package/src/components/ChoiceChipGroup/ChoiceChipGroup.vue +70 -0
- package/src/components/ChoiceChipGroup/index.ts +2 -0
- package/src/components/ColorPicker/ColorArea.vue +159 -0
- package/src/components/ColorPicker/ColorPicker.test.ts +250 -0
- package/src/components/ColorPicker/ColorPicker.vue +339 -0
- package/src/components/ColorPicker/ColorSlider.vue +191 -0
- package/src/components/ColorPicker/index.ts +7 -0
- package/src/components/Combobox/Combobox.test.ts +891 -0
- package/src/components/Combobox/Combobox.vue +934 -0
- package/src/components/Combobox/index.ts +2 -0
- package/src/components/DataTable/DataTable.test.ts +1221 -0
- package/src/components/DataTable/DataTable.vue +1415 -0
- package/src/components/DataTable/index.ts +10 -0
- package/src/components/DatePicker/DatePicker.test.ts +625 -0
- package/src/components/DatePicker/DatePicker.vue +1586 -0
- package/src/components/DatePicker/index.ts +2 -0
- package/src/components/Drawer/Drawer.test.ts +336 -0
- package/src/components/Drawer/Drawer.vue +466 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Dropdown/Dropdown.test.ts +607 -0
- package/src/components/Dropdown/Dropdown.vue +807 -0
- package/src/components/Dropdown/DropdownItem.vue +227 -0
- package/src/components/Dropdown/DropdownSeparator.vue +14 -0
- package/src/components/Dropdown/DropdownSub.vue +104 -0
- package/src/components/Dropdown/DropdownSubContent.vue +187 -0
- package/src/components/Dropdown/DropdownSubTrigger.vue +151 -0
- package/src/components/Dropdown/index.ts +14 -0
- package/src/components/EmptyState/EmptyState.test.ts +180 -0
- package/src/components/EmptyState/EmptyState.vue +137 -0
- package/src/components/EmptyState/index.ts +2 -0
- package/src/components/FileUpload/FileUpload.test.ts +1151 -0
- package/src/components/FileUpload/FileUpload.vue +1042 -0
- package/src/components/FileUpload/index.ts +2 -0
- package/src/components/Heading/Heading.test.ts +107 -0
- package/src/components/Heading/Heading.vue +67 -0
- package/src/components/Heading/index.ts +2 -0
- package/src/components/Icon/Icon.test.ts +157 -0
- package/src/components/Icon/Icon.vue +86 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.test.ts +273 -0
- package/src/components/Input/Input.vue +388 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Layout/Container.vue +67 -0
- package/src/components/Layout/Grid.vue +159 -0
- package/src/components/Layout/GridItem.vue +154 -0
- package/src/components/Layout/Layout.test.ts +202 -0
- package/src/components/Layout/Stack.vue +128 -0
- package/src/components/Layout/index.ts +9 -0
- package/src/components/Layout/keys.ts +7 -0
- package/src/components/Modal/Modal.test.ts +311 -0
- package/src/components/Modal/Modal.vue +336 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Pagination/Pagination.test.ts +303 -0
- package/src/components/Pagination/Pagination.vue +212 -0
- package/src/components/Pagination/index.ts +3 -0
- package/src/components/Pagination/utils.ts +86 -0
- package/src/components/Popover/Popover.test.ts +285 -0
- package/src/components/Popover/Popover.vue +441 -0
- package/src/components/Popover/index.ts +2 -0
- package/src/components/Progress/Progress.test.ts +361 -0
- package/src/components/Progress/Progress.vue +363 -0
- package/src/components/Progress/index.ts +7 -0
- package/src/components/Radio/Radio.test.ts +216 -0
- package/src/components/Radio/Radio.vue +214 -0
- package/src/components/Radio/index.ts +2 -0
- package/src/components/Rating/Rating.test.ts +319 -0
- package/src/components/Rating/Rating.vue +247 -0
- package/src/components/Rating/index.ts +2 -0
- package/src/components/SegmentedControl/SegmentedControl.test.ts +292 -0
- package/src/components/SegmentedControl/SegmentedControl.vue +288 -0
- package/src/components/SegmentedControl/index.ts +2 -0
- package/src/components/Select/Select.test.ts +589 -0
- package/src/components/Select/Select.vue +666 -0
- package/src/components/Select/index.ts +2 -0
- package/src/components/Sidebar/Sidebar.test.ts +301 -0
- package/src/components/Sidebar/SidebarGroup.vue +103 -0
- package/src/components/Sidebar/SidebarItem.vue +196 -0
- package/src/components/Sidebar/SidebarLayout.vue +42 -0
- package/src/components/Sidebar/SidebarRoot.vue +122 -0
- package/src/components/Sidebar/index.ts +11 -0
- package/src/components/Sidebar/keys.ts +14 -0
- package/src/components/Skeleton/Skeleton.test.ts +130 -0
- package/src/components/Skeleton/Skeleton.vue +104 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Slider/Slider.test.ts +416 -0
- package/src/components/Slider/Slider.vue +435 -0
- package/src/components/Slider/index.ts +2 -0
- package/src/components/Slider/utils.ts +91 -0
- package/src/components/Spinner/Spinner.test.ts +79 -0
- package/src/components/Spinner/Spinner.vue +159 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/SpireProvider/SpireProvider.vue +71 -0
- package/src/components/SpireProvider/index.ts +11 -0
- package/src/components/Stepper/Stepper.test.ts +221 -0
- package/src/components/Stepper/StepperContent.vue +51 -0
- package/src/components/Stepper/StepperItem.vue +89 -0
- package/src/components/Stepper/StepperRoot.vue +101 -0
- package/src/components/Stepper/StepperSeparator.vue +52 -0
- package/src/components/Stepper/StepperTrigger.vue +144 -0
- package/src/components/Stepper/index.ts +11 -0
- package/src/components/Stepper/keys.ts +27 -0
- package/src/components/Switch/Switch.test.ts +214 -0
- package/src/components/Switch/Switch.vue +235 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Tabs/Tabs.test.ts +363 -0
- package/src/components/Tabs/Tabs.vue +318 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Text/Text.test.ts +154 -0
- package/src/components/Text/Text.vue +100 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/Textarea/Textarea.test.ts +432 -0
- package/src/components/Textarea/Textarea.vue +411 -0
- package/src/components/Textarea/index.ts +2 -0
- package/src/components/TimePicker/TimePicker.test.ts +352 -0
- package/src/components/TimePicker/TimePicker.vue +569 -0
- package/src/components/TimePicker/index.ts +2 -0
- package/src/components/Timeline/Timeline.test.ts +193 -0
- package/src/components/Timeline/Timeline.vue +111 -0
- package/src/components/Timeline/TimelineItem.vue +167 -0
- package/src/components/Timeline/index.ts +13 -0
- package/src/components/Timeline/keys.ts +21 -0
- package/src/components/Toast/ToastItem.test.ts +289 -0
- package/src/components/Toast/ToastItem.vue +370 -0
- package/src/components/Toast/ToastProvider.test.ts +158 -0
- package/src/components/Toast/ToastProvider.vue +181 -0
- package/src/components/Toast/index.ts +83 -0
- package/src/components/Toast/toastState.test.ts +165 -0
- package/src/components/Toast/toastState.ts +161 -0
- package/src/components/ToggleButton/ToggleButton.test.ts +166 -0
- package/src/components/ToggleButton/ToggleButton.vue +197 -0
- package/src/components/ToggleButton/index.ts +2 -0
- package/src/components/ToggleGroup/ToggleGroup.test.ts +181 -0
- package/src/components/ToggleGroup/ToggleGroup.vue +130 -0
- package/src/components/ToggleGroup/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.test.ts +238 -0
- package/src/components/Tooltip/Tooltip.vue +217 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/TreeView/TreeView.test.ts +357 -0
- package/src/components/TreeView/TreeView.vue +251 -0
- package/src/components/TreeView/TreeViewItem.vue +288 -0
- package/src/components/TreeView/index.ts +11 -0
- package/src/components/TreeView/keys.ts +35 -0
- package/src/composables/index.ts +12 -0
- package/src/composables/useClickOutside.ts +36 -0
- package/src/composables/useClipboard.ts +35 -0
- package/src/composables/useEventListener.ts +48 -0
- package/src/composables/useFocusTrap.ts +58 -0
- package/src/composables/useHoverReveal.ts +98 -0
- package/src/composables/useId.ts +10 -0
- package/src/composables/useMagnetic.ts +171 -0
- package/src/composables/useRelativePosition.ts +127 -0
- package/src/composables/useRipple.ts +146 -0
- package/src/composables/useScrollLock.ts +25 -0
- package/src/composables/useSpireConfig.ts +27 -0
- package/src/composables/useStagger.ts +224 -0
- package/src/config/icons.test.ts +115 -0
- package/src/config/icons.ts +170 -0
- package/src/index.ts +361 -0
- package/src/styles/depth.css +129 -0
- package/src/styles/effects.css +169 -0
- package/src/styles/fallback.css +152 -0
- package/src/styles/main.css +25 -0
- package/src/styles/mood.css +211 -0
- package/src/styles/motion.css +159 -0
- package/src/styles/reset.css +97 -0
- package/src/styles/theme.css +708 -0
- package/src/styles/tokens.css +183 -0
- package/src/utils/.gitkeep +0 -0
- package/src/utils/color.ts +277 -0
- package/src/utils/date.test.ts +522 -0
- package/src/utils/date.ts +380 -0
- package/src/utils/index.ts +23 -0
- package/src/utils/object.test.ts +80 -0
- package/src/utils/object.ts +25 -0
- package/src/utils/string.test.ts +64 -0
- package/src/utils/string.ts +32 -0
- package/src/utils/time.ts +156 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { provide, ref, toRef, computed, type Component } from 'vue'
|
|
3
|
+
|
|
4
|
+
export type CardVariant = 'elevated' | 'outline' | 'ghost'
|
|
5
|
+
export type CardPadding = 'none' | 'sm' | 'md' | 'lg'
|
|
6
|
+
|
|
7
|
+
export interface CardProps {
|
|
8
|
+
/** Visual style variant */
|
|
9
|
+
variant?: CardVariant
|
|
10
|
+
/** Render as different element (article, section, aside, etc.) */
|
|
11
|
+
as?: string | Component
|
|
12
|
+
/** Makes the entire card clickable with overlay pattern */
|
|
13
|
+
interactive?: boolean
|
|
14
|
+
/** Horizontal layout - image on side instead of top */
|
|
15
|
+
horizontal?: boolean
|
|
16
|
+
/** Disabled state for interactive cards */
|
|
17
|
+
disabled?: boolean
|
|
18
|
+
/** Loading state - shows skeleton overlay */
|
|
19
|
+
loading?: boolean
|
|
20
|
+
/** Custom padding override */
|
|
21
|
+
padding?: CardPadding
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<CardProps>(), {
|
|
25
|
+
variant: 'elevated',
|
|
26
|
+
as: 'div',
|
|
27
|
+
interactive: false,
|
|
28
|
+
horizontal: false,
|
|
29
|
+
disabled: false,
|
|
30
|
+
loading: false,
|
|
31
|
+
padding: 'md'
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
(e: 'click', event: MouseEvent): void
|
|
36
|
+
}>()
|
|
37
|
+
|
|
38
|
+
const hasHeader = ref(false)
|
|
39
|
+
const hasTopImage = ref(false)
|
|
40
|
+
|
|
41
|
+
function registerHeader() {
|
|
42
|
+
hasHeader.value = true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function registerTopImage() {
|
|
46
|
+
hasTopImage.value = true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
provide('card', {
|
|
50
|
+
variant: toRef(props, 'variant'),
|
|
51
|
+
horizontal: toRef(props, 'horizontal'),
|
|
52
|
+
interactive: toRef(props, 'interactive'),
|
|
53
|
+
loading: toRef(props, 'loading'),
|
|
54
|
+
padding: toRef(props, 'padding'),
|
|
55
|
+
hasHeader,
|
|
56
|
+
hasTopImage,
|
|
57
|
+
registerHeader,
|
|
58
|
+
registerTopImage
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
function handleClick(event: MouseEvent) {
|
|
62
|
+
if (props.disabled || props.loading) return
|
|
63
|
+
if (props.interactive) {
|
|
64
|
+
emit('click', event)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
69
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
70
|
+
event.preventDefault()
|
|
71
|
+
handleClick(event as unknown as MouseEvent)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const isClickable = computed(() => props.interactive && !props.disabled && !props.loading)
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<component
|
|
80
|
+
:is="as"
|
|
81
|
+
class="ui-card"
|
|
82
|
+
:class="[
|
|
83
|
+
`ui-card--${variant}`,
|
|
84
|
+
`ui-card--padding-${padding}`,
|
|
85
|
+
{
|
|
86
|
+
'ui-card--interactive': interactive,
|
|
87
|
+
'ui-card--horizontal': horizontal,
|
|
88
|
+
'ui-card--disabled': disabled,
|
|
89
|
+
'ui-card--loading': loading
|
|
90
|
+
}
|
|
91
|
+
]"
|
|
92
|
+
:tabindex="isClickable ? 0 : undefined"
|
|
93
|
+
:role="isClickable ? 'button' : undefined"
|
|
94
|
+
:aria-disabled="disabled || undefined"
|
|
95
|
+
:aria-busy="loading || undefined"
|
|
96
|
+
@click="handleClick"
|
|
97
|
+
@keydown="handleKeydown"
|
|
98
|
+
>
|
|
99
|
+
<slot />
|
|
100
|
+
<div v-if="loading" class="ui-card__skeleton" aria-hidden="true" />
|
|
101
|
+
</component>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<style scoped>
|
|
105
|
+
.ui-card {
|
|
106
|
+
position: relative;
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
background: var(--card-bg);
|
|
110
|
+
border-radius: var(--card-radius);
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
font-family: var(--font-sans);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.ui-card--elevated {
|
|
116
|
+
border: 1px solid var(--card-border);
|
|
117
|
+
box-shadow: var(--card-shadow);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.ui-card--outline {
|
|
121
|
+
border: 1px solid var(--card-border);
|
|
122
|
+
box-shadow: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.ui-card--ghost {
|
|
126
|
+
border: none;
|
|
127
|
+
box-shadow: none;
|
|
128
|
+
background: transparent;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ui-card--interactive {
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
transition:
|
|
134
|
+
box-shadow var(--duration-fast) var(--ease-default),
|
|
135
|
+
border-color var(--duration-fast) var(--ease-default);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ui-card--interactive::after {
|
|
139
|
+
content: '';
|
|
140
|
+
position: absolute;
|
|
141
|
+
inset: 0;
|
|
142
|
+
z-index: 0;
|
|
143
|
+
border-radius: inherit;
|
|
144
|
+
pointer-events: none;
|
|
145
|
+
transition: background-color var(--duration-fast) var(--ease-default);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.ui-card--interactive:hover:not(.ui-card--disabled):not(.ui-card--loading)::after {
|
|
149
|
+
background-color: oklch(0 0 0 / calc(var(--depth-shadow-opacity, 0.1) * 0.3));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.ui-card--interactive:active:not(.ui-card--disabled):not(.ui-card--loading)::after {
|
|
153
|
+
background-color: oklch(0 0 0 / var(--depth-inset-opacity, 0.06));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.ui-card--interactive.ui-card--elevated:hover:not(.ui-card--disabled):not(.ui-card--loading) {
|
|
157
|
+
box-shadow: var(--card-shadow-hover);
|
|
158
|
+
border-color: var(--card-border-hover);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ui-card--interactive > :deep(*) {
|
|
162
|
+
position: relative;
|
|
163
|
+
z-index: 1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.ui-card--interactive:focus-visible {
|
|
167
|
+
outline: 2px solid var(--ring-color);
|
|
168
|
+
outline-offset: 2px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.ui-card--horizontal {
|
|
172
|
+
flex-direction: row;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.ui-card--disabled {
|
|
176
|
+
opacity: 0.6;
|
|
177
|
+
cursor: not-allowed;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.ui-card--loading {
|
|
181
|
+
cursor: wait;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ui-card__skeleton {
|
|
185
|
+
position: absolute;
|
|
186
|
+
inset: 0;
|
|
187
|
+
z-index: 10;
|
|
188
|
+
background: linear-gradient(
|
|
189
|
+
90deg,
|
|
190
|
+
var(--card-bg) 25%,
|
|
191
|
+
var(--color-stone-100) 50%,
|
|
192
|
+
var(--card-bg) 75%
|
|
193
|
+
);
|
|
194
|
+
background-size: 200% 100%;
|
|
195
|
+
animation: card-skeleton-shimmer 1.5s infinite;
|
|
196
|
+
border-radius: inherit;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@keyframes card-skeleton-shimmer {
|
|
200
|
+
0% { background-position: 200% 0; }
|
|
201
|
+
100% { background-position: -200% 0; }
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@media (max-width: 640px) {
|
|
205
|
+
.ui-card--horizontal {
|
|
206
|
+
flex-direction: column;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, computed, type Ref } from 'vue'
|
|
3
|
+
import type { CardPadding } from './Card.vue'
|
|
4
|
+
|
|
5
|
+
export interface CardContentProps {
|
|
6
|
+
/** Remove default padding */
|
|
7
|
+
flush?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<CardContentProps>(), {
|
|
11
|
+
flush: false
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const cardContext = inject<{
|
|
15
|
+
hasHeader: { value: boolean }
|
|
16
|
+
hasTopImage: { value: boolean }
|
|
17
|
+
padding: Ref<CardPadding>
|
|
18
|
+
} | null>('card', null)
|
|
19
|
+
|
|
20
|
+
const removeTopPadding = computed(() => cardContext?.hasHeader?.value ?? false)
|
|
21
|
+
const paddingSize = computed(() => cardContext?.padding?.value ?? 'md')
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div
|
|
26
|
+
class="ui-card__content"
|
|
27
|
+
:class="[
|
|
28
|
+
`ui-card__content--padding-${paddingSize}`,
|
|
29
|
+
{
|
|
30
|
+
'ui-card__content--flush': flush,
|
|
31
|
+
'ui-card__content--no-top-padding': removeTopPadding
|
|
32
|
+
}
|
|
33
|
+
]"
|
|
34
|
+
>
|
|
35
|
+
<slot />
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<style scoped>
|
|
40
|
+
.ui-card__content {
|
|
41
|
+
color: var(--card-text);
|
|
42
|
+
flex: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ui-card__content--padding-none { padding: 0; }
|
|
46
|
+
.ui-card__content--padding-sm { padding: var(--space-2); }
|
|
47
|
+
.ui-card__content--padding-md { padding: var(--space-3); }
|
|
48
|
+
.ui-card__content--padding-lg { padding: var(--space-4); }
|
|
49
|
+
|
|
50
|
+
.ui-card__content--flush {
|
|
51
|
+
padding: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ui-card__content--no-top-padding {
|
|
55
|
+
padding-top: 0;
|
|
56
|
+
}
|
|
57
|
+
</style>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, computed, type Ref } from 'vue'
|
|
3
|
+
import type { CardPadding } from './Card.vue'
|
|
4
|
+
|
|
5
|
+
export interface CardFooterProps {
|
|
6
|
+
/** Content alignment */
|
|
7
|
+
align?: 'start' | 'center' | 'end' | 'between'
|
|
8
|
+
/** Remove separator border */
|
|
9
|
+
borderless?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<CardFooterProps>(), {
|
|
13
|
+
align: 'end',
|
|
14
|
+
borderless: false
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const cardContext = inject<{
|
|
18
|
+
padding: Ref<CardPadding>
|
|
19
|
+
} | null>('card', null)
|
|
20
|
+
|
|
21
|
+
const paddingSize = computed(() => cardContext?.padding?.value ?? 'md')
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div
|
|
26
|
+
class="ui-card__footer"
|
|
27
|
+
:class="[
|
|
28
|
+
`ui-card__footer--${align}`,
|
|
29
|
+
`ui-card__footer--padding-${paddingSize}`,
|
|
30
|
+
{ 'ui-card__footer--borderless': borderless }
|
|
31
|
+
]"
|
|
32
|
+
>
|
|
33
|
+
<slot />
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<style scoped>
|
|
38
|
+
.ui-card__footer {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: var(--space-3);
|
|
42
|
+
background: var(--card-footer-bg);
|
|
43
|
+
border-top: 1px solid var(--card-footer-border);
|
|
44
|
+
margin-top: auto;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ui-card__footer--padding-none { padding: 0; }
|
|
48
|
+
.ui-card__footer--padding-sm { padding: var(--space-2); }
|
|
49
|
+
.ui-card__footer--padding-md { padding: var(--space-3); }
|
|
50
|
+
.ui-card__footer--padding-lg { padding: var(--space-4); }
|
|
51
|
+
|
|
52
|
+
.ui-card__footer--start {
|
|
53
|
+
justify-content: flex-start;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.ui-card__footer--center {
|
|
57
|
+
justify-content: center;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ui-card__footer--end {
|
|
61
|
+
justify-content: flex-end;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ui-card__footer--between {
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ui-card__footer--borderless {
|
|
69
|
+
border-top: none;
|
|
70
|
+
background: transparent;
|
|
71
|
+
}
|
|
72
|
+
</style>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, onMounted, useSlots, computed, type Ref } from 'vue'
|
|
3
|
+
import type { CardPadding } from './Card.vue'
|
|
4
|
+
|
|
5
|
+
export interface CardHeaderProps {
|
|
6
|
+
/** Title text (alternative to slot) */
|
|
7
|
+
title?: string
|
|
8
|
+
/** Subtitle text (alternative to slot) */
|
|
9
|
+
subtitle?: string
|
|
10
|
+
/** Aligns header content */
|
|
11
|
+
align?: 'start' | 'center'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<CardHeaderProps>(), {
|
|
15
|
+
align: 'start'
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const slots = useSlots()
|
|
19
|
+
|
|
20
|
+
const cardContext = inject<{
|
|
21
|
+
registerHeader: () => void
|
|
22
|
+
padding: Ref<CardPadding>
|
|
23
|
+
} | null>('card', null)
|
|
24
|
+
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
cardContext?.registerHeader()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const hasActions = !!slots.actions
|
|
30
|
+
const paddingSize = computed(() => cardContext?.padding?.value ?? 'md')
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div
|
|
35
|
+
class="ui-card__header"
|
|
36
|
+
:class="[
|
|
37
|
+
`ui-card__header--${align}`,
|
|
38
|
+
`ui-card__header--padding-${paddingSize}`
|
|
39
|
+
]"
|
|
40
|
+
>
|
|
41
|
+
<div class="ui-card__header-content">
|
|
42
|
+
<slot name="title">
|
|
43
|
+
<h3 v-if="title" class="ui-card__title">{{ title }}</h3>
|
|
44
|
+
</slot>
|
|
45
|
+
<slot name="subtitle">
|
|
46
|
+
<p v-if="subtitle" class="ui-card__subtitle">{{ subtitle }}</p>
|
|
47
|
+
</slot>
|
|
48
|
+
<slot />
|
|
49
|
+
</div>
|
|
50
|
+
<div v-if="$slots.actions" class="ui-card__header-actions">
|
|
51
|
+
<slot name="actions" />
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<style scoped>
|
|
57
|
+
.ui-card__header {
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: flex-start;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
gap: var(--space-4);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ui-card__header--padding-none { padding: 0; }
|
|
65
|
+
.ui-card__header--padding-sm { padding: var(--space-2); }
|
|
66
|
+
.ui-card__header--padding-md { padding: var(--space-3); }
|
|
67
|
+
.ui-card__header--padding-lg { padding: var(--space-4); }
|
|
68
|
+
|
|
69
|
+
.ui-card__header--start {
|
|
70
|
+
text-align: start;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ui-card__header--center {
|
|
74
|
+
text-align: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.ui-card__header--center .ui-card__header-content {
|
|
79
|
+
align-items: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ui-card__header-content {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
gap: var(--space-1);
|
|
86
|
+
min-width: 0;
|
|
87
|
+
flex: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.ui-card__header-actions {
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: var(--space-2);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ui-card__title {
|
|
98
|
+
margin: 0;
|
|
99
|
+
font-size: var(--text-lg);
|
|
100
|
+
font-weight: var(--font-semibold);
|
|
101
|
+
line-height: var(--leading-tight);
|
|
102
|
+
color: var(--card-title);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.ui-card__subtitle {
|
|
106
|
+
margin: 0;
|
|
107
|
+
font-size: var(--text-sm);
|
|
108
|
+
line-height: var(--leading-normal);
|
|
109
|
+
color: var(--card-subtitle);
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, onMounted, computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
export type CardImagePosition = 'top' | 'bottom' | 'left' | 'right' | 'background'
|
|
5
|
+
export type CardImageAspectRatio = '16:9' | '4:3' | '3:2' | '1:1' | 'auto'
|
|
6
|
+
export type CardImageFit = 'cover' | 'contain' | 'fill'
|
|
7
|
+
|
|
8
|
+
export interface CardImageProps {
|
|
9
|
+
/** Image source URL */
|
|
10
|
+
src: string
|
|
11
|
+
/** Alt text for accessibility */
|
|
12
|
+
alt: string
|
|
13
|
+
/** Aspect ratio constraint */
|
|
14
|
+
aspectRatio?: CardImageAspectRatio
|
|
15
|
+
/** Image position within card */
|
|
16
|
+
position?: CardImagePosition
|
|
17
|
+
/** Object-fit behavior */
|
|
18
|
+
fit?: CardImageFit
|
|
19
|
+
/** Loading attribute for native lazy loading */
|
|
20
|
+
loading?: 'eager' | 'lazy'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const props = withDefaults(defineProps<CardImageProps>(), {
|
|
24
|
+
aspectRatio: 'auto',
|
|
25
|
+
position: 'top',
|
|
26
|
+
fit: 'cover',
|
|
27
|
+
loading: 'lazy'
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const cardContext = inject<{
|
|
31
|
+
horizontal: { value: boolean }
|
|
32
|
+
registerTopImage: () => void
|
|
33
|
+
} | null>('card', null)
|
|
34
|
+
|
|
35
|
+
onMounted(() => {
|
|
36
|
+
if (props.position === 'top') {
|
|
37
|
+
cardContext?.registerTopImage()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const aspectRatioValue = computed(() => {
|
|
42
|
+
const ratioMap: Record<string, string> = {
|
|
43
|
+
'16:9': '16 / 9',
|
|
44
|
+
'4:3': '4 / 3',
|
|
45
|
+
'3:2': '3 / 2',
|
|
46
|
+
'1:1': '1 / 1',
|
|
47
|
+
'auto': 'auto'
|
|
48
|
+
}
|
|
49
|
+
return ratioMap[props.aspectRatio]
|
|
50
|
+
})
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div
|
|
55
|
+
class="ui-card__image"
|
|
56
|
+
:class="[`ui-card__image--${position}`]"
|
|
57
|
+
:style="aspectRatio !== 'auto' ? { '--aspect-ratio': aspectRatioValue } : undefined"
|
|
58
|
+
>
|
|
59
|
+
<img
|
|
60
|
+
:src="src"
|
|
61
|
+
:alt="alt"
|
|
62
|
+
:loading="loading"
|
|
63
|
+
class="ui-card__image-img"
|
|
64
|
+
:class="[`ui-card__image-img--${fit}`]"
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<style scoped>
|
|
70
|
+
.ui-card__image {
|
|
71
|
+
position: relative;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
flex-shrink: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ui-card__image--top,
|
|
77
|
+
.ui-card__image--bottom {
|
|
78
|
+
width: 100%;
|
|
79
|
+
aspect-ratio: var(--aspect-ratio, auto);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ui-card__image--left,
|
|
83
|
+
.ui-card__image--right {
|
|
84
|
+
width: 40%;
|
|
85
|
+
min-width: 120px;
|
|
86
|
+
max-width: 300px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ui-card__image--background {
|
|
90
|
+
position: absolute;
|
|
91
|
+
inset: 0;
|
|
92
|
+
z-index: 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.ui-card__image-img {
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
display: block;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ui-card__image-img--cover {
|
|
102
|
+
object-fit: cover;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.ui-card__image-img--contain {
|
|
106
|
+
object-fit: contain;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.ui-card__image-img--fill {
|
|
110
|
+
object-fit: fill;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.ui-card__image--bottom {
|
|
114
|
+
order: 999;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@media (max-width: 640px) {
|
|
118
|
+
.ui-card__image--left,
|
|
119
|
+
.ui-card__image--right {
|
|
120
|
+
width: 100%;
|
|
121
|
+
max-width: none;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as Card } from './Card.vue'
|
|
2
|
+
export type { CardProps, CardVariant, CardPadding } from './Card.vue'
|
|
3
|
+
|
|
4
|
+
export { default as CardHeader } from './CardHeader.vue'
|
|
5
|
+
export type { CardHeaderProps } from './CardHeader.vue'
|
|
6
|
+
|
|
7
|
+
export { default as CardContent } from './CardContent.vue'
|
|
8
|
+
export type { CardContentProps } from './CardContent.vue'
|
|
9
|
+
|
|
10
|
+
export { default as CardFooter } from './CardFooter.vue'
|
|
11
|
+
export type { CardFooterProps } from './CardFooter.vue'
|
|
12
|
+
|
|
13
|
+
export { default as CardImage } from './CardImage.vue'
|
|
14
|
+
export type { CardImageProps, CardImagePosition, CardImageAspectRatio, CardImageFit } from './CardImage.vue'
|