Skip to content

Commit

Permalink
feat: many additions for new table structure (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiaking committed Dec 25, 2023
1 parent 26e179b commit 6fc9c71
Show file tree
Hide file tree
Showing 25 changed files with 1,227 additions and 187 deletions.
69 changes: 41 additions & 28 deletions lib/components/SButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const props = defineProps<{
type?: Type
mode?: Mode
icon?: any
leadIcon?: any
trailIcon?: any
iconMode?: Mode
label?: string
labelMode?: Mode
Expand All @@ -52,12 +54,15 @@ const emit = defineEmits<{
(e: 'disabled-click'): void
}>()
const _leadIcon = computed(() => props.leadIcon ?? props.icon)
const classes = computed(() => [
props.size ?? 'medium',
props.type ?? 'fill',
props.mode ?? 'default',
{ 'has-label': props.label },
{ 'has-icon': props.icon },
{ 'has-lead-icon': _leadIcon.value },
{ 'has-trail-icon': props.trailIcon },
{ loading: props.loading },
{ rounded: props.rounded },
{ block: props.block },
Expand Down Expand Up @@ -104,12 +109,15 @@ function handleClick(): void {
@click="handleClick"
>
<span class="content">
<span v-if="icon" class="icon" :class="iconMode">
<SIcon :icon="icon" class="icon-svg" />
<span v-if="_leadIcon" class="icon" :class="iconMode">
<SIcon :icon="_leadIcon" class="icon-svg" />
</span>
<span v-if="label" class="label" :class="labelMode">
{{ label }}
</span>
<span v-if="trailIcon" class="icon" :class="iconMode">
<SIcon :icon="trailIcon" class="icon-svg" />
</span>
</span>
<transition name="fade">
Expand Down Expand Up @@ -192,59 +200,64 @@ function handleClick(): void {
min-height: 28px;
font-size: var(--button-font-size, var(--button-mini-font-size));
&.rounded { border-radius: 16px; }
&.has-label { padding: var(--button-padding, 0 12px); }
&.has-label.has-icon { padding: var(--button-padding, 0 10px 0 8px); }
.content { gap: 4px; }
.icon-svg { width: 16px; height: 16px; }
&.rounded { border-radius: 16px; }
&.has-label { padding: var(--button-padding, 0 12px); }
&.has-label.has-lead-icon { padding: var(--button-padding, 0 10px 0 8px); }
&.has-label.has-trail-icon { padding: var(--button-padding, 0 8px 0 10px); }
.content { gap: 4px; }
.icon-svg { width: 16px; height: 16px; }
}
.SButton.small {
min-width: 32px;
min-height: 32px;
font-size: var(--button-font-size, var(--button-small-font-size));
&.rounded { border-radius: 16px; }
&.has-label { padding: var(--button-padding, 0 12px); }
&.has-label.has-icon { padding: var(--button-padding, 0 10px 0 8px); }
.content { gap: 6px; }
.icon-svg { width: 16px; height: 16px; }
&.rounded { border-radius: 16px; }
&.has-label { padding: var(--button-padding, 0 12px); }
&.has-label.has-lead-icon { padding: var(--button-padding, 0 10px 0 8px); }
&.has-label.has-trail-icon { padding: var(--button-padding, 0 8px 0 10px); }
.content { gap: 6px; }
.icon-svg { width: 16px; height: 16px; }
}
.SButton.medium {
min-width: 40px;
min-height: 40px;
font-size: var(--button-font-size, var(--button-medium-font-size));
&.rounded { border-radius: 20px; }
&.has-label { padding: var(--button-padding, 0 16px); }
&.has-label.has-icon { padding: var(--button-padding, 0 12px 0 10px); }
.content { gap: 6px; }
.icon-svg { width: 18px; height: 18px; }
&.rounded { border-radius: 20px; }
&.has-label { padding: var(--button-padding, 0 16px); }
&.has-label.has-lead-icon { padding: var(--button-padding, 0 12px 0 10px); }
&.has-label.has-trail-icon { padding: var(--button-padding, 0 10px 0 12px); }
.content { gap: 6px; }
.icon-svg { width: 18px; height: 18px; }
}
.SButton.large {
min-width: 48px;
min-height: 48px;
font-size: var(--button-font-size, var(--button-large-font-size));
&.rounded { border-radius: 24px; }
&.has-label { padding: var(--button-padding, 0 20px); }
&.has-label.has-icon { padding: var(--button-padding, 0 14px 0 12px); }
.content { gap: 6px; }
.icon-svg { width: 18px; height: 18px; }
&.rounded { border-radius: 24px; }
&.has-label { padding: var(--button-padding, 0 20px); }
&.has-label.has-lead-icon { padding: var(--button-padding, 0 14px 0 12px); }
&.has-label.has-trail-icon { padding: var(--button-padding, 0 12px 0 14px); }
.content { gap: 6px; }
.icon-svg { width: 18px; height: 18px; }
}
.SButton.jumbo {
min-width: 64px;
min-height: 64px;
font-size: var(--button-font-size, var(--button-jumbo-font-size));
&.rounded { border-radius: 32px; }
&.has-label { padding: var(--button-padding, 0 24px); }
&.has-label.has-icon { padding: var(--button-padding, 0 20px 0 18px); }
.content { gap: 8px; }
.icon-svg { width: 20px; height: 20px; }
&.rounded { border-radius: 32px; }
&.has-label { padding: var(--button-padding, 0 24px); }
&.has-label.has-lead-icon { padding: var(--button-padding, 0 20px 0 18px); }
&.has-label.has-trail-icon { padding: var(--button-padding, 0 18px 0 20px); }
.content { gap: 8px; }
.icon-svg { width: 20px; height: 20px; }
}
.SButton.disabled {
Expand Down
4 changes: 2 additions & 2 deletions lib/components/SCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const props = defineProps<{
mode?: Mode
}>()
const { isCollapsed } = provideCardState()
const classes = computed(() => [
props.size,
props.mode ?? 'neutral',
{ collapsed: isCollapsed.value }
])
const { isCollapsed } = provideCardState()
</script>

<template>
Expand Down
38 changes: 32 additions & 6 deletions lib/components/SCardBlock.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
<script setup lang="ts">
import { computed } from 'vue'
import { type CardBlockSize, provideCardBlockSize } from '../composables/Card'
export type { CardBlockSize as Size }
// @deprecated Use CSS utility classes instead.
export type Space = 'compact' | 'wide' | 'xwide'
defineProps<{
const props = defineProps<{
size?: CardBlockSize
// @deprecated Use CSS utility classes instead.
space?: Space
}>()
provideCardBlockSize(computed(() => props.size ?? null))
</script>

<template>
<div class="SCardBlock" :class="[space]">
<div class="SCardBlock" :class="[size, space]">
<slot />
</div>
</template>

<style scoped lang="postcss">
.SCardBlock {
padding: var(--card-padding, 0);
background-color: var(--c-bg-elv-3);
&.compact { padding: 24px; }
&.wide { padding: 32px; }
&.xwide { padding: 48px; }
&.compact { padding: 12px; }
&.wide { padding: 16px; }
&.xwide { padding: 24px; }
}
.SCard > .SCardBlock:first-child {
Expand All @@ -31,4 +41,20 @@ defineProps<{
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
.SCardBlock.xsmall,
.SCardBlock.small,
.SCardBlock.medium,
.SCardBlock.large,
.SCardBlock.xlarge {
display: flex;
align-items: center;
width: 100%;
}
.SCardBlock.xsmall { height: 40px; }
.SCardBlock.small { height: 48px; }
.SCardBlock.medium { height: 56px; }
.SCardBlock.large { height: 64px; }
.SCardBlock.xlarge { height: 80px; }
</style>
50 changes: 50 additions & 0 deletions lib/components/SControl.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useCardBlockSize } from '../composables/Card'
import { type ControlSize, provideControlSize } from '../composables/Control'
export type { ControlSize as Size }
const props = defineProps<{
size?: ControlSize
}>()
const cardSize = useCardBlockSize()
const sizeDict = {
xsmall: 'small',
small: 'small',
medium: 'small',
large: 'medium',
xlarge: 'medium',
null: null
} as const
const _size = computed(() => {
return props.size ?? sizeDict[cardSize.value ?? 'null'] ?? 'small'
})
const classes = computed(() => [
_size.value,
cardSize.value ? `card-size-${cardSize.value}` : null
])
provideControlSize(_size)
</script>

<template>
<div class="SControl" :class="classes">
<slot />
</div>
</template>

<style scoped lang="postcss">
.SControl {
display: flex;
align-items: center;
flex-grow: 1;
}
.SControl.small { gap: 8px; height: 32px; }
.SControl.medium { gap: 12px; height: 40px; }
</style>
45 changes: 45 additions & 0 deletions lib/components/SControlButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { useControlSize } from '../composables/Control'
import SButton, { type Mode, type Tooltip, type Type } from './SButton.vue'
defineProps<{
tag?: string
type?: Type
mode?: Mode
icon?: any
iconMode?: Mode
label?: string
labelMode?: Mode
href?: string
loading?: boolean
disabled?: boolean
tooltip?: Tooltip
}>()
defineEmits<{
(e: 'click'): void
}>()
const size = useControlSize()
</script>

<template>
<div class="SControlButton">
<SButton
:tag="tag"
:size="size"
:type="type"
:mode="mode"
:icon="icon"
:icon-mode="iconMode"
:label="label"
:label-mode="labelMode"
:href="href"
:tooltip="tooltip"
block
:loading="loading"
:disabled="disabled"
@click="$emit('click')"
/>
</div>
</template>
24 changes: 24 additions & 0 deletions lib/components/SControlCenter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { provideControlPosition } from '../composables/Control'
provideControlPosition('center')
</script>

<template>
<div class="SControlCenter">
<slot />
</div>
</template>

<style scoped lang="postcss">
.SControlCenter {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
flex-shrink: 0;
}
.SControl.small .SControlCenter { gap: 8px; }
.SControl.medium .SControlCenter { gap: 12px; }
</style>

0 comments on commit 6fc9c71

Please sign in to comment.