fds-vue-core 2.1.1 → 2.1.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/fds-vue-core.cjs.js +3 -2
- package/dist/fds-vue-core.cjs.js.map +1 -1
- package/dist/fds-vue-core.css +1 -1
- package/dist/fds-vue-core.es.js +3 -2
- package/dist/fds-vue-core.es.js.map +1 -1
- package/package.json +2 -3
- package/scripts/sync-peers-from-dev.mjs +29 -0
- package/scripts/sync-vscode-settings.mjs +44 -0
- package/src/.DS_Store +0 -0
- package/src/App.vue +0 -133
- package/src/apply.css +0 -60
- package/src/assets/icons.ts +0 -517
- package/src/components/Blocks/FdsBlockAlert/FdsBlockAlert.stories.ts +0 -94
- package/src/components/Blocks/FdsBlockAlert/FdsBlockAlert.vue +0 -112
- package/src/components/Blocks/FdsBlockAlert/types.ts +0 -12
- package/src/components/Blocks/FdsBlockContent/FdsBlockContent.stories.ts +0 -110
- package/src/components/Blocks/FdsBlockContent/FdsBlockContent.vue +0 -66
- package/src/components/Blocks/FdsBlockContent/types.ts +0 -6
- package/src/components/Blocks/FdsBlockExpander/FdsBlockExpander.stories.ts +0 -123
- package/src/components/Blocks/FdsBlockExpander/FdsBlockExpander.vue +0 -87
- package/src/components/Blocks/FdsBlockExpander/types.ts +0 -8
- package/src/components/Blocks/FdsBlockInfo/FdsBlockInfo.stories.ts +0 -110
- package/src/components/Blocks/FdsBlockInfo/FdsBlockInfo.vue +0 -98
- package/src/components/Blocks/FdsBlockInfo/types.ts +0 -8
- package/src/components/Blocks/FdsBlockLink/FdsBlockLink.css +0 -9
- package/src/components/Blocks/FdsBlockLink/FdsBlockLink.stories.ts +0 -179
- package/src/components/Blocks/FdsBlockLink/FdsBlockLink.vue +0 -149
- package/src/components/Blocks/FdsBlockLink/types.ts +0 -14
- package/src/components/Buttons/ButtonBaseProps.ts +0 -18
- package/src/components/Buttons/FdsButtonCopy/FdsButtonCopy.stories.ts +0 -53
- package/src/components/Buttons/FdsButtonCopy/FdsButtonCopy.vue +0 -87
- package/src/components/Buttons/FdsButtonCopy/types.ts +0 -8
- package/src/components/Buttons/FdsButtonDownload/FdsButtonDownload.stories.ts +0 -111
- package/src/components/Buttons/FdsButtonDownload/FdsButtonDownload.vue +0 -187
- package/src/components/Buttons/FdsButtonIcon/FdsButtonIcon.stories.ts +0 -55
- package/src/components/Buttons/FdsButtonIcon/FdsButtonIcon.vue +0 -57
- package/src/components/Buttons/FdsButtonIcon/types.ts +0 -12
- package/src/components/Buttons/FdsButtonMinor/FdsButtonMinor.stories.ts +0 -68
- package/src/components/Buttons/FdsButtonMinor/FdsButtonMinor.vue +0 -126
- package/src/components/Buttons/FdsButtonPrimary/FdsButtonPrimary.stories.ts +0 -86
- package/src/components/Buttons/FdsButtonPrimary/FdsButtonPrimary.vue +0 -107
- package/src/components/Buttons/FdsButtonSecondary/FdsButtonSecondary.stories.ts +0 -68
- package/src/components/Buttons/FdsButtonSecondary/FdsButtonSecondary.vue +0 -107
- package/src/components/FdsIcon/FdsIcon.stories.ts +0 -69
- package/src/components/FdsIcon/FdsIcon.vue +0 -34
- package/src/components/FdsIcon/types.ts +0 -9
- package/src/components/FdsModal/FdsModal.stories.ts +0 -241
- package/src/components/FdsModal/FdsModal.vue +0 -261
- package/src/components/FdsModal/types.ts +0 -12
- package/src/components/FdsPagination/FdsPagination.stories.ts +0 -109
- package/src/components/FdsPagination/FdsPagination.vue +0 -193
- package/src/components/FdsPagination/types.ts +0 -6
- package/src/components/FdsSearchSelect/FdsSearchSelect.stories.ts +0 -428
- package/src/components/FdsSearchSelect/FdsSearchSelect.vue +0 -610
- package/src/components/FdsSearchSelect/types.ts +0 -25
- package/src/components/FdsSpinner/FdsSpinner.stories.ts +0 -31
- package/src/components/FdsSpinner/FdsSpinner.vue +0 -90
- package/src/components/FdsSpinner/types.ts +0 -6
- package/src/components/FdsSticker/FdsSticker.stories.ts +0 -148
- package/src/components/FdsSticker/FdsSticker.vue +0 -44
- package/src/components/FdsSticker/types.ts +0 -4
- package/src/components/FdsTreeView/FdsTreeView.stories.ts +0 -136
- package/src/components/FdsTreeView/FdsTreeView.vue +0 -162
- package/src/components/FdsTreeView/TreeNode.vue +0 -383
- package/src/components/FdsTreeView/types.ts +0 -141
- package/src/components/FdsTreeView/useTreeState.ts +0 -607
- package/src/components/FdsTreeView/utils.ts +0 -65
- package/src/components/FdsTruncatedText/FdsTruncatedText.stories.ts +0 -78
- package/src/components/FdsTruncatedText/FdsTruncatedText.vue +0 -85
- package/src/components/FdsTruncatedText/types.ts +0 -6
- package/src/components/Form/FdsCheckbox/FdsCheckbox.stories.ts +0 -275
- package/src/components/Form/FdsCheckbox/FdsCheckbox.vue +0 -155
- package/src/components/Form/FdsCheckbox/types.ts +0 -10
- package/src/components/Form/FdsInput/FdsInput.stories.ts +0 -319
- package/src/components/Form/FdsInput/FdsInput.vue +0 -233
- package/src/components/Form/FdsInput/types.ts +0 -25
- package/src/components/Form/FdsRadio/FdsRadio.stories.ts +0 -63
- package/src/components/Form/FdsRadio/FdsRadio.vue +0 -88
- package/src/components/Form/FdsRadio/types.ts +0 -12
- package/src/components/Form/FdsSelect/FdsSelect.stories.ts +0 -78
- package/src/components/Form/FdsSelect/FdsSelect.vue +0 -136
- package/src/components/Form/FdsSelect/types.ts +0 -13
- package/src/components/Form/FdsTextarea/FdsTextarea.stories.ts +0 -52
- package/src/components/Form/FdsTextarea/FdsTextarea.vue +0 -110
- package/src/components/Form/FdsTextarea/types.ts +0 -12
- package/src/components/Table/FdsTable/FdsTable.stories.ts +0 -221
- package/src/components/Table/FdsTable/FdsTable.vue +0 -25
- package/src/components/Table/FdsTable/types.ts +0 -4
- package/src/components/Table/FdsTableHead/FdsTableHead.stories.ts +0 -151
- package/src/components/Table/FdsTableHead/FdsTableHead.vue +0 -54
- package/src/components/Table/FdsTableHead/types.ts +0 -5
- package/src/components/Tabs/FdsTabs/FdsTabs.stories.ts +0 -247
- package/src/components/Tabs/FdsTabs/FdsTabs.vue +0 -27
- package/src/components/Tabs/FdsTabs/types.ts +0 -4
- package/src/components/Tabs/FdsTabsItem/FdsTabsItem.vue +0 -125
- package/src/components/Tabs/FdsTabsItem/types.ts +0 -16
- package/src/components/Typography/FdsHeading/FdsHeading.stories.ts +0 -93
- package/src/components/Typography/FdsHeading/FdsHeading.vue +0 -51
- package/src/components/Typography/FdsHeading/types.ts +0 -5
- package/src/components/Typography/FdsListHeading/FdsListHeading.stories.ts +0 -58
- package/src/components/Typography/FdsListHeading/FdsListHeading.vue +0 -62
- package/src/components/Typography/FdsListHeading/types.ts +0 -8
- package/src/components/Typography/FdsSeparator/FdsSeparator.stories.ts +0 -31
- package/src/components/Typography/FdsSeparator/FdsSeparator.vue +0 -5
- package/src/components/Typography/FdsText/FdsText.stories.ts +0 -66
- package/src/components/Typography/FdsText/FdsText.vue +0 -28
- package/src/components/Typography/FdsText/types.ts +0 -3
- package/src/composables/useBoldQuery.ts +0 -29
- package/src/composables/useElementFinalSize.ts +0 -24
- package/src/composables/useHasSlots.ts +0 -17
- package/src/composables/useIsPid.ts +0 -48
- package/src/docs/Start/Start.mdx +0 -12
- package/src/docs/Usage.md +0 -117
- package/src/fonts.css +0 -28
- package/src/global-components.ts +0 -38
- package/src/index.ts +0 -180
- package/src/main.ts +0 -7
- package/src/slot-styles.css +0 -93
- package/src/style.css +0 -89
- package/src/tokens.css +0 -252
- package/tsconfig.base.json +0 -4
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
-
import FdsBlockAlert from './FdsBlockAlert.vue'
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof FdsBlockAlert> = {
|
|
5
|
-
title: 'FDS/Blocks/FdsBlockAlert',
|
|
6
|
-
component: FdsBlockAlert,
|
|
7
|
-
tags: ['autodocs'],
|
|
8
|
-
argTypes: {
|
|
9
|
-
closeable: { control: { type: 'boolean' } },
|
|
10
|
-
collapsable: { control: { type: 'boolean' } },
|
|
11
|
-
expanded: { control: { type: 'boolean' } },
|
|
12
|
-
label: { control: { type: 'text' } },
|
|
13
|
-
default: { control: { type: 'text' } },
|
|
14
|
-
locale: { control: { type: 'select' }, options: ['sv', 'en'] },
|
|
15
|
-
},
|
|
16
|
-
args: {
|
|
17
|
-
visible: true,
|
|
18
|
-
closeable: false,
|
|
19
|
-
collapsable: false,
|
|
20
|
-
expanded: false,
|
|
21
|
-
label: 'About this component',
|
|
22
|
-
default: 'This is an alert block with some important information.',
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default meta
|
|
27
|
-
type Story = StoryObj<typeof meta>
|
|
28
|
-
|
|
29
|
-
const blockAlertTransform = (storyContext: {
|
|
30
|
-
args?: {
|
|
31
|
-
visible?: boolean
|
|
32
|
-
label?: string
|
|
33
|
-
closeable?: boolean
|
|
34
|
-
collapsable?: boolean
|
|
35
|
-
expanded?: boolean
|
|
36
|
-
locale?: string
|
|
37
|
-
default?: string
|
|
38
|
-
}
|
|
39
|
-
}) => {
|
|
40
|
-
const args = storyContext?.args || {}
|
|
41
|
-
const attrs = []
|
|
42
|
-
|
|
43
|
-
if (args.label) attrs.push(`label="${args.label}"`)
|
|
44
|
-
if (args.closeable) attrs.push(':closeable="true"')
|
|
45
|
-
if (args.collapsable) attrs.push(':collapsable="true"')
|
|
46
|
-
if (args.expanded) attrs.push(':expanded="true"')
|
|
47
|
-
if (args.locale && args.locale !== 'sv') attrs.push(`locale="${args.locale}"`)
|
|
48
|
-
|
|
49
|
-
const attrsStr = attrs.length ? ` ${attrs.join(' ')}` : ''
|
|
50
|
-
const content = args.default ? `\n <p>${args.default}</p>\n` : ''
|
|
51
|
-
return `<FdsBlockAlert${attrsStr}>${content}</FdsBlockAlert>`
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const Default: Story = {
|
|
55
|
-
render: (args) => ({
|
|
56
|
-
components: { FdsBlockAlert },
|
|
57
|
-
setup: () => ({ args }),
|
|
58
|
-
template: `<FdsBlockAlert v-bind="args"><p>{{ args.default }}</p></FdsBlockAlert>`,
|
|
59
|
-
}),
|
|
60
|
-
parameters: {
|
|
61
|
-
docs: {
|
|
62
|
-
source: {
|
|
63
|
-
transform: blockAlertTransform,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
args: {
|
|
68
|
-
label: 'About this component',
|
|
69
|
-
default: 'This is an alert block with some important information.',
|
|
70
|
-
},
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const WithLabel: Story = {
|
|
74
|
-
render: () => ({
|
|
75
|
-
components: { FdsBlockAlert },
|
|
76
|
-
template: `
|
|
77
|
-
<FdsBlockAlert label="Information">
|
|
78
|
-
<p>This alert block has a <a href="test" class="link">test</a> label and provides important information to the user.</p>
|
|
79
|
-
</FdsBlockAlert>
|
|
80
|
-
`,
|
|
81
|
-
}),
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const Collapsable: Story = {
|
|
85
|
-
render: () => ({
|
|
86
|
-
components: { FdsBlockAlert },
|
|
87
|
-
template: `
|
|
88
|
-
<FdsBlockAlert label="Collapsable Alert" collapsable>
|
|
89
|
-
<p>This alert block can be collapsed and expanded. The content below is only visible when expanded.</p>
|
|
90
|
-
<p>Additional details about the alert can be shown here.</p>
|
|
91
|
-
</FdsBlockAlert>
|
|
92
|
-
`,
|
|
93
|
-
}),
|
|
94
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useHasSlot } from '@/composables/useHasSlots'
|
|
3
|
-
import { computed, ref, watch } from 'vue'
|
|
4
|
-
import FdsButtonIcon from '@/components/Buttons/FdsButtonIcon/FdsButtonIcon.vue'
|
|
5
|
-
import FdsIcon from '@/components/FdsIcon/FdsIcon.vue'
|
|
6
|
-
import type { FdsAlertBlockProps } from './types'
|
|
7
|
-
|
|
8
|
-
const props = withDefaults(defineProps<FdsAlertBlockProps>(), {
|
|
9
|
-
id: undefined,
|
|
10
|
-
visible: true,
|
|
11
|
-
closeable: false,
|
|
12
|
-
collapsable: false,
|
|
13
|
-
expanded: false,
|
|
14
|
-
label: '',
|
|
15
|
-
locale: 'sv',
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
const emit = defineEmits<{
|
|
19
|
-
(e: 'close'): void
|
|
20
|
-
(e: 'toggle'): void
|
|
21
|
-
(e: 'update:visible', value: boolean): void
|
|
22
|
-
}>()
|
|
23
|
-
|
|
24
|
-
const isExpanded = ref(props.expanded)
|
|
25
|
-
const isVisible = ref<boolean>(props.visible)
|
|
26
|
-
const expandLabel = computed(() => (props.locale === 'sv' ? 'Visa mer' : 'Show more'))
|
|
27
|
-
const collapseLabel = computed(() => (props.locale === 'sv' ? 'Visa mindre' : 'Show less'))
|
|
28
|
-
const closeLabel = computed(() => (props.locale === 'sv' ? 'Stäng' : 'Close'))
|
|
29
|
-
|
|
30
|
-
const hasSlot = useHasSlot()
|
|
31
|
-
|
|
32
|
-
watch(
|
|
33
|
-
() => props.visible,
|
|
34
|
-
(v) => {
|
|
35
|
-
isVisible.value = v
|
|
36
|
-
},
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
const alertClasses = computed(() => [
|
|
40
|
-
'bg-yellow-200 border-yellow-300 border-1 rounded-md p-4 mb-4',
|
|
41
|
-
(props.collapsable && !isExpanded.value) || !hasSlot.value ? 'pb-4' : 'pb-6',
|
|
42
|
-
])
|
|
43
|
-
|
|
44
|
-
const autoId = `fds-alert-${Math.random().toString(36).slice(2, 9)}`
|
|
45
|
-
const alertId = computed(() => props.id ?? autoId)
|
|
46
|
-
|
|
47
|
-
function handleClose() {
|
|
48
|
-
isVisible.value = false
|
|
49
|
-
emit('update:visible', false)
|
|
50
|
-
emit('close')
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function handleToggle() {
|
|
54
|
-
isExpanded.value = !isExpanded.value
|
|
55
|
-
emit('toggle')
|
|
56
|
-
}
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
|
-
<template>
|
|
60
|
-
<div
|
|
61
|
-
v-if="isVisible"
|
|
62
|
-
:id="alertId"
|
|
63
|
-
:class="alertClasses"
|
|
64
|
-
>
|
|
65
|
-
<div>
|
|
66
|
-
<div>
|
|
67
|
-
<div
|
|
68
|
-
v-if="label"
|
|
69
|
-
class="font-bold w-full justify-between items-center h-[24px] flex gap-2"
|
|
70
|
-
:class="{ 'mb-4': (isExpanded || !collapsable) && hasSlot }"
|
|
71
|
-
>
|
|
72
|
-
<div class="flex items-center gap-2">
|
|
73
|
-
<FdsIcon
|
|
74
|
-
name="alert"
|
|
75
|
-
:size="24"
|
|
76
|
-
class="fill-yellow-700"
|
|
77
|
-
/>
|
|
78
|
-
<span>{{ label }}</span>
|
|
79
|
-
</div>
|
|
80
|
-
<div class="relative">
|
|
81
|
-
<FdsButtonIcon
|
|
82
|
-
v-if="closeable"
|
|
83
|
-
icon="cross"
|
|
84
|
-
:size="24"
|
|
85
|
-
@click="handleClose"
|
|
86
|
-
:ariaLabel="closeLabel"
|
|
87
|
-
:class="['fill-gray-900! hover:bg-gray-100 active:bg-gray-200']"
|
|
88
|
-
/>
|
|
89
|
-
<FdsButtonIcon
|
|
90
|
-
v-if="collapsable"
|
|
91
|
-
icon="arrowDown"
|
|
92
|
-
:size="24"
|
|
93
|
-
@click="handleToggle"
|
|
94
|
-
:ariaLabel="isExpanded ? collapseLabel : expandLabel"
|
|
95
|
-
:class="[
|
|
96
|
-
'fill-gray-900! hover:bg-gray-100 active:bg-gray-200',
|
|
97
|
-
'[&_svg]:transition-transform [&_svg]:duration-200',
|
|
98
|
-
isExpanded ? '[&_svg]:-rotate-180' : '[&_svg]:rotate-0',
|
|
99
|
-
]"
|
|
100
|
-
/>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
<div
|
|
104
|
-
v-if="isExpanded || !collapsable"
|
|
105
|
-
class="fds-block-alert-slot mb-0-last-child"
|
|
106
|
-
>
|
|
107
|
-
<slot />
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
112
|
-
</template>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type icons from '@/assets/icons'
|
|
2
|
-
|
|
3
|
-
export interface FdsAlertBlockProps {
|
|
4
|
-
id?: string
|
|
5
|
-
visible?: boolean
|
|
6
|
-
closeable?: boolean
|
|
7
|
-
collapsable?: boolean
|
|
8
|
-
expanded?: boolean
|
|
9
|
-
label?: string
|
|
10
|
-
locale?: 'sv' | 'en'
|
|
11
|
-
icon?: keyof typeof icons
|
|
12
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
-
import FdsBlockContent from './FdsBlockContent.vue'
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof FdsBlockContent> = {
|
|
5
|
-
title: 'FDS/Blocks/FdsBlockContent',
|
|
6
|
-
component: FdsBlockContent,
|
|
7
|
-
tags: ['autodocs'],
|
|
8
|
-
argTypes: {
|
|
9
|
-
heading: { control: { type: 'text' } },
|
|
10
|
-
borderLeft: { control: { type: 'radio' }, options: ['', 'green', 'yellow', 'red'] },
|
|
11
|
-
tight: { control: { type: 'boolean' } },
|
|
12
|
-
headerInfo: {
|
|
13
|
-
control: { type: 'text' },
|
|
14
|
-
description: 'Header info slot (HTML only in Storybook, supports Vue components when consumed)',
|
|
15
|
-
},
|
|
16
|
-
default: { control: { type: 'text' } },
|
|
17
|
-
},
|
|
18
|
-
args: {
|
|
19
|
-
heading: 'About this component',
|
|
20
|
-
borderLeft: undefined,
|
|
21
|
-
tight: false,
|
|
22
|
-
headerInfo: '',
|
|
23
|
-
default:
|
|
24
|
-
'The Content Block can contain various types and amounts of content. We recommend using multiple instances of it for grouping related content.',
|
|
25
|
-
},
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default meta
|
|
29
|
-
type Story = StoryObj<typeof meta>
|
|
30
|
-
|
|
31
|
-
const blockContentTransform = (storyContext: {
|
|
32
|
-
args?: {
|
|
33
|
-
heading?: string
|
|
34
|
-
headerInfo?: string
|
|
35
|
-
default?: string
|
|
36
|
-
tight?: boolean
|
|
37
|
-
color?: string
|
|
38
|
-
borderLeft?: boolean
|
|
39
|
-
}
|
|
40
|
-
}) => {
|
|
41
|
-
const args = storyContext?.args || {}
|
|
42
|
-
const attrs = []
|
|
43
|
-
if (args.heading) attrs.push(`heading="${args.heading}"`)
|
|
44
|
-
if (args.tight) attrs.push(':tight="true"')
|
|
45
|
-
if (args.color && args.color !== 'blue') attrs.push(`color="${args.color}"`)
|
|
46
|
-
if (args.borderLeft) attrs.push(':borderLeft="true"')
|
|
47
|
-
|
|
48
|
-
const attrsStr = attrs.length ? ` ${attrs.join(' ')}` : ''
|
|
49
|
-
let content = ''
|
|
50
|
-
|
|
51
|
-
if (args.headerInfo || args.default) {
|
|
52
|
-
content = '\n'
|
|
53
|
-
if (args.headerInfo) {
|
|
54
|
-
content += ` <template #headerInfo>\n <div v-html="${args.headerInfo}" />\n </template>\n`
|
|
55
|
-
}
|
|
56
|
-
if (args.default) {
|
|
57
|
-
content += ` <p>${args.default}</p>\n`
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return `<FdsBlockContent${attrsStr}>${content}</FdsBlockContent>`
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const Default: Story = {
|
|
65
|
-
render: (args) => ({
|
|
66
|
-
components: { FdsBlockContent },
|
|
67
|
-
setup: () => ({ args }),
|
|
68
|
-
template: `
|
|
69
|
-
<FdsBlockContent v-bind="args">
|
|
70
|
-
<template #headerInfo>
|
|
71
|
-
<div v-if="args.headerInfo" v-html="args.headerInfo"></div>
|
|
72
|
-
</template>
|
|
73
|
-
<p>{{ args.default }}</p>
|
|
74
|
-
</FdsBlockContent>`,
|
|
75
|
-
}),
|
|
76
|
-
parameters: {
|
|
77
|
-
docs: {
|
|
78
|
-
source: {
|
|
79
|
-
transform: blockContentTransform,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
args: {
|
|
84
|
-
heading: 'About this component',
|
|
85
|
-
default:
|
|
86
|
-
'The Content Block can contain various types and amounts of content. We recommend using multiple instances of it for grouping related content.',
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const WithBorderLeft: Story = {
|
|
91
|
-
render: () => ({
|
|
92
|
-
components: { FdsBlockContent },
|
|
93
|
-
template: `
|
|
94
|
-
<FdsBlockContent heading="About this component" borderLeft="var(--color-green-600" icon="alert">
|
|
95
|
-
<p>The Content Block can contain various types and amounts of content. We recommend using multiple instances of it for grouping related content.</p>
|
|
96
|
-
</FdsBlockContent>
|
|
97
|
-
`,
|
|
98
|
-
}),
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export const Tight: Story = {
|
|
102
|
-
render: () => ({
|
|
103
|
-
components: { FdsBlockContent },
|
|
104
|
-
template: `
|
|
105
|
-
<FdsBlockContent heading="About this component" tight>
|
|
106
|
-
<p>The Content Block can contain various types and amounts of content. We recommend using multiple instances of it for grouping related content.</p>
|
|
107
|
-
</FdsBlockContent>
|
|
108
|
-
`,
|
|
109
|
-
}),
|
|
110
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, type Slot } from 'vue'
|
|
3
|
-
import type { FdsContentBlockProps } from './types'
|
|
4
|
-
import { useHasSlot } from '@/composables/useHasSlots'
|
|
5
|
-
|
|
6
|
-
const hasSlot = useHasSlot()
|
|
7
|
-
|
|
8
|
-
const props = withDefaults(defineProps<FdsContentBlockProps>(), {
|
|
9
|
-
borderLeft: undefined,
|
|
10
|
-
tight: false,
|
|
11
|
-
heading: undefined,
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const contentClasses = computed(() => [
|
|
15
|
-
'rounded-md p-4 bg-white mb-4',
|
|
16
|
-
props.tight && 'pb-2',
|
|
17
|
-
props.tight && 'p-4!',
|
|
18
|
-
props.borderLeft && 'border-l-4',
|
|
19
|
-
hasSlot.value ? 'pb-6' : 'pb-4',
|
|
20
|
-
])
|
|
21
|
-
|
|
22
|
-
const headerClasses = computed(() => ['mt-0 mb-4 text-lg font-bold tracking-wide', !hasSlot.value && 'mb-0!'])
|
|
23
|
-
|
|
24
|
-
const borderLeftStyle = computed(() => {
|
|
25
|
-
if (!props.borderLeft) return {}
|
|
26
|
-
|
|
27
|
-
const colorMap: Record<string, string> = {
|
|
28
|
-
green: 'var(--color-green-600)',
|
|
29
|
-
yellow: 'var(--color-yellow-400)',
|
|
30
|
-
red: 'var(--color-red-500)',
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return { 'border-left-color': colorMap[props.borderLeft] || props.borderLeft }
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const autoId = `fds-content-block-${Math.random().toString(36).slice(2, 9)}`
|
|
37
|
-
const contentBlockId = computed(() => props.id ?? autoId)
|
|
38
|
-
|
|
39
|
-
defineSlots<{
|
|
40
|
-
default?: Slot
|
|
41
|
-
headerInfo?: Slot
|
|
42
|
-
}>()
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
<template>
|
|
46
|
-
<div
|
|
47
|
-
:id="contentBlockId"
|
|
48
|
-
:class="contentClasses"
|
|
49
|
-
:style="borderLeftStyle"
|
|
50
|
-
>
|
|
51
|
-
<header
|
|
52
|
-
v-if="heading"
|
|
53
|
-
class="flex items-start justify-between gap-4"
|
|
54
|
-
>
|
|
55
|
-
<div class="flex items-center gap-3">
|
|
56
|
-
<h3 :class="headerClasses">{{ heading }}</h3>
|
|
57
|
-
</div>
|
|
58
|
-
<div class="flex items-start gap-3">
|
|
59
|
-
<slot name="headerInfo" />
|
|
60
|
-
</div>
|
|
61
|
-
</header>
|
|
62
|
-
<div class="mb-0-last-child">
|
|
63
|
-
<slot />
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
</template>
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
-
import icons from '@/assets/icons'
|
|
3
|
-
import FdsBlockExpander from './FdsBlockExpander.vue'
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof FdsBlockExpander> = {
|
|
6
|
-
title: 'FDS/Blocks/FdsBlockExpander',
|
|
7
|
-
component: FdsBlockExpander,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
argTypes: {
|
|
10
|
-
disabled: { control: { type: 'boolean' } },
|
|
11
|
-
open: { control: { type: 'boolean' } },
|
|
12
|
-
label: { control: { type: 'text' } },
|
|
13
|
-
preIcon: { control: { type: 'select' }, options: Object.keys(icons) },
|
|
14
|
-
default: { control: { type: 'text' } },
|
|
15
|
-
},
|
|
16
|
-
args: {
|
|
17
|
-
disabled: false,
|
|
18
|
-
open: false,
|
|
19
|
-
label: 'Expandable Content',
|
|
20
|
-
preIcon: undefined,
|
|
21
|
-
default: 'This is the expandable content that shows when the block is opened.',
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default meta
|
|
26
|
-
type Story = StoryObj<typeof meta>
|
|
27
|
-
|
|
28
|
-
const blockExpanderTransform = (storyContext: {
|
|
29
|
-
args?: {
|
|
30
|
-
label?: string
|
|
31
|
-
preIcon?: string
|
|
32
|
-
open?: boolean
|
|
33
|
-
disabled?: boolean
|
|
34
|
-
default?: string
|
|
35
|
-
}
|
|
36
|
-
}) => {
|
|
37
|
-
const args = storyContext?.args || {}
|
|
38
|
-
const attrs = []
|
|
39
|
-
|
|
40
|
-
if (args.label) attrs.push(`label="${args.label}"`)
|
|
41
|
-
if (args.preIcon) attrs.push(`preIcon="${args.preIcon}"`)
|
|
42
|
-
if (args.open) attrs.push(':open="true"')
|
|
43
|
-
if (args.disabled) attrs.push(':disabled="true"')
|
|
44
|
-
|
|
45
|
-
const attrsStr = attrs.length ? ` ${attrs.join(' ')}` : ''
|
|
46
|
-
const content = args.default ? `\n <p>${args.default}</p>\n` : ''
|
|
47
|
-
return `<FdsBlockExpander${attrsStr}>${content}</FdsBlockExpander>`
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const Default: Story = {
|
|
51
|
-
render: (args) => ({
|
|
52
|
-
components: { FdsBlockExpander },
|
|
53
|
-
setup: () => ({ args }),
|
|
54
|
-
template: `<FdsBlockExpander v-bind="args"><p>{{ args.default }}</p></FdsBlockExpander>`,
|
|
55
|
-
}),
|
|
56
|
-
parameters: {
|
|
57
|
-
docs: {
|
|
58
|
-
source: {
|
|
59
|
-
transform: blockExpanderTransform,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
args: {
|
|
64
|
-
label: 'Expandable Content',
|
|
65
|
-
default: 'This is the expandable content that shows when the block is opened.',
|
|
66
|
-
},
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const WithIcon: Story = {
|
|
70
|
-
render: () => ({
|
|
71
|
-
components: { FdsBlockExpander },
|
|
72
|
-
template: `
|
|
73
|
-
<FdsBlockExpander label="Settings" preIcon="settings">
|
|
74
|
-
<div class="space-y-2">
|
|
75
|
-
<p>This expander block has an icon in the header.</p>
|
|
76
|
-
<p>Click to expand and see more content.</p>
|
|
77
|
-
</div>
|
|
78
|
-
</FdsBlockExpander>
|
|
79
|
-
`,
|
|
80
|
-
}),
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const Open: Story = {
|
|
84
|
-
render: () => ({
|
|
85
|
-
components: { FdsBlockExpander },
|
|
86
|
-
template: `
|
|
87
|
-
<FdsBlockExpander label="Pre-opened Content" open>
|
|
88
|
-
<p>This expander block starts in the open state.</p>
|
|
89
|
-
<p>You can still click the header to close it.</p>
|
|
90
|
-
</FdsBlockExpander>
|
|
91
|
-
`,
|
|
92
|
-
}),
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export const Disabled: Story = {
|
|
96
|
-
render: () => ({
|
|
97
|
-
components: { FdsBlockExpander },
|
|
98
|
-
template: `
|
|
99
|
-
<FdsBlockExpander label="Disabled Block" disabled>
|
|
100
|
-
<p>This expander block is disabled and cannot be interacted with.</p>
|
|
101
|
-
</FdsBlockExpander>
|
|
102
|
-
`,
|
|
103
|
-
}),
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const MultipleBlocks: Story = {
|
|
107
|
-
render: () => ({
|
|
108
|
-
components: { FdsBlockExpander },
|
|
109
|
-
template: `
|
|
110
|
-
<div class="space-y-4">
|
|
111
|
-
<FdsBlockExpander label="First Block" preIcon="information">
|
|
112
|
-
<p>Content for the first expander block.</p>
|
|
113
|
-
</FdsBlockExpander>
|
|
114
|
-
<FdsBlockExpander label="Second Block" preIcon="settings">
|
|
115
|
-
<p>Content for the second expander block.</p>
|
|
116
|
-
</FdsBlockExpander>
|
|
117
|
-
<FdsBlockExpander label="Third Block" preIcon="alert">
|
|
118
|
-
<p>Content for the third expander block.</p>
|
|
119
|
-
</FdsBlockExpander>
|
|
120
|
-
</div>
|
|
121
|
-
`,
|
|
122
|
-
}),
|
|
123
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, ref, watch } from 'vue'
|
|
3
|
-
import FdsIcon from '@/components/FdsIcon/FdsIcon.vue'
|
|
4
|
-
import type { FdsExpanderBlockProps } from './types'
|
|
5
|
-
|
|
6
|
-
const props = withDefaults(defineProps<FdsExpanderBlockProps>(), {
|
|
7
|
-
disabled: false,
|
|
8
|
-
label: '',
|
|
9
|
-
open: false,
|
|
10
|
-
preIcon: undefined,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
const emit = defineEmits<{
|
|
14
|
-
(e: 'toggle'): void
|
|
15
|
-
}>()
|
|
16
|
-
|
|
17
|
-
const isOpen = ref(props.open)
|
|
18
|
-
|
|
19
|
-
// Watch for changes to the open prop
|
|
20
|
-
watch(
|
|
21
|
-
() => props.open,
|
|
22
|
-
(newValue) => {
|
|
23
|
-
isOpen.value = newValue
|
|
24
|
-
},
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
const expanderClasses = computed(() => [
|
|
28
|
-
'expander-root block w-full rounded-2xl mb-4 shadow-[0_4px_16px_0_rgba(59,130,246,0.2)] transition-colors',
|
|
29
|
-
props.disabled && 'shadow-none border-2 border-gray-200 border-dashed',
|
|
30
|
-
])
|
|
31
|
-
|
|
32
|
-
const headerClasses = computed(() => [
|
|
33
|
-
'flex w-full items-start text-left justify-between bg-white text-blue-600 rounded-2xl p-[calc(1rem-2px)] border-2 border-white transition-colors border-2 border-white hover:border-blue-500 active:bg-blue_t-100 active:border-white focus-visible:border-blue-500 focus-visible:border-dashed focus-visible:outline-0',
|
|
34
|
-
props.disabled ? 'cursor-not-allowed hover:border-2 hover:border-transparent active:bg-white' : 'cursor-pointer',
|
|
35
|
-
isOpen.value ? 'rounded-b-none' : 'rounded-b-2xl',
|
|
36
|
-
])
|
|
37
|
-
|
|
38
|
-
function handleToggle() {
|
|
39
|
-
if (props.disabled) return
|
|
40
|
-
isOpen.value = !isOpen.value
|
|
41
|
-
emit('toggle')
|
|
42
|
-
}
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
<template>
|
|
46
|
-
<div :class="expanderClasses">
|
|
47
|
-
<button
|
|
48
|
-
type="button"
|
|
49
|
-
:class="headerClasses"
|
|
50
|
-
@click="handleToggle"
|
|
51
|
-
>
|
|
52
|
-
<span class="inline-flex items-center">
|
|
53
|
-
<span
|
|
54
|
-
v-if="preIcon"
|
|
55
|
-
class="flex items-center mr-4"
|
|
56
|
-
>
|
|
57
|
-
<FdsIcon
|
|
58
|
-
:name="preIcon"
|
|
59
|
-
:size="24"
|
|
60
|
-
class="fill-blue-500"
|
|
61
|
-
:class="{ 'fill-gray-500': disabled }"
|
|
62
|
-
/>
|
|
63
|
-
</span>
|
|
64
|
-
<span class="inline-flex items-center">
|
|
65
|
-
<span
|
|
66
|
-
class="font-bold font-heading text-lg leading-md"
|
|
67
|
-
:class="{ 'text-gray-500': disabled }"
|
|
68
|
-
>{{ label }}</span
|
|
69
|
-
>
|
|
70
|
-
</span>
|
|
71
|
-
</span>
|
|
72
|
-
<FdsIcon
|
|
73
|
-
name="arrowDown"
|
|
74
|
-
:size="24"
|
|
75
|
-
class="ml-4 transition-transform duration-200 fill-blue-500 min-w-6 min-h-6"
|
|
76
|
-
:class="{ 'rotate-180': isOpen, 'fill-gray-500': disabled }"
|
|
77
|
-
/>
|
|
78
|
-
</button>
|
|
79
|
-
<div
|
|
80
|
-
:aria-hidden="!isOpen"
|
|
81
|
-
class="mb-0-last-child block px-4 pb-6 rounded-b-2xl bg-white"
|
|
82
|
-
v-show="isOpen"
|
|
83
|
-
>
|
|
84
|
-
<slot />
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
</template>
|