Skip to content

Commit

Permalink
fix: slottable button
Browse files Browse the repository at this point in the history
  • Loading branch information
azuradara committed Jan 11, 2025
1 parent 28f9cb5 commit e3cc7cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
31 changes: 10 additions & 21 deletions packages/celeste-vue/src/components/button/button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const props = withDefaults(defineProps<ButtonProps>(), {
size: 'md',
variant: 'fill',
type: 'primary',
iconPosition: 'trailing',
as: 'button',
});
</script>
Expand All @@ -18,9 +17,6 @@ export interface ButtonProps extends PrimitiveProps {
size?: 'xxs' | 'xs' | 'sm' | 'md';
type?: 'primary' | 'neutral' | 'error';
variant?: 'fill' | 'stroke' | 'lighter' | 'ghost';
iconPosition?: 'leading' | 'trailing';
icon?: string;
label?: string;
}
</script>

Expand All @@ -35,11 +31,8 @@ export interface ButtonProps extends PrimitiveProps {
`celeste-button-variant-${variant}`,
props.class,
)"
:role="as === 'a' ? 'link' : 'button'"
>
<i v-if="icon && iconPosition === 'leading'" :class="icon" />
<span v-if="label" role="presentation">{{ label }}</span>
<i v-if="icon && iconPosition === 'trailing'" :class="icon" />
<slot />
</Primitive>
</template>

Expand All @@ -51,25 +44,25 @@ $size-map: (
height: 28px,
border-radius: var(--radius-8),
padding: var(--spacing-4) var(--spacing-6),
gap: var(--spacing-2),
gap: var(--spacing-4),
),
'xs': (
height: 32px,
border-radius: var(--radius-8),
padding: var(--spacing-6),
gap: var(--spacing-2),
padding: var(--spacing-6) var(--spacing-8),
gap: var(--spacing-4),
),
'sm': (
height: 36px,
border-radius: var(--radius-8),
padding: var(--spacing-8),
gap: var(--spacing-4),
padding: var(--spacing-8) var(--spacing-10),
gap: var(--spacing-6),
),
'md': (
height: 40px,
border-radius: var(--radius-10),
padding: var(--spacing-10),
gap: var(--spacing-4),
padding: var(--spacing-10) var(--spacing-12),
gap: var(--spacing-6),
),
);
$type-map: (
Expand Down Expand Up @@ -232,6 +225,7 @@ $hover-map: (
border: none;
border: 1px solid transparent;
background-color: transparent;
font: var(--label-sm);
text-decoration: none;
cursor: pointer;
Expand All @@ -241,12 +235,7 @@ $hover-map: (
cursor: default;
}
span {
padding: 0 4px;
font: var(--label-sm);
}
i {
:deep(i) {
width: 20px;
height: 20px;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/celeste-vue/src/components/button/link-button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export interface LinkButtonProps extends PrimitiveProps {
height: 20px;
font: var(--label-sm);
i {
:deep(i) {
width: 20px;
height: 20px;
}
Expand All @@ -81,7 +81,7 @@ export interface LinkButtonProps extends PrimitiveProps {
height: 16px;
font: var(--label-xs);
i {
:deep(i) {
width: 16px;
height: 16px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type Story = StoryObj<typeof Button>;

export const Default: Story = {
args: {
label: 'Button',
icon: 'i-celeste-arrow-right-s-line',
size: 'md',
type: 'primary',
},
Expand All @@ -25,6 +23,8 @@ export const Default: Story = {
},
template: `
<Button v-bind="args">
Continue
<i i-celeste-arrow-right-s-line></i>
</Button>
`,
}),
Expand Down

0 comments on commit e3cc7cf

Please sign in to comment.