-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
249 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,59 @@ | ||
<script setup lang="ts"> | ||
import BuiButton from './BuiButton.vue' | ||
import { ButtonColor } from './types' | ||
import { ButtonColor, ButtonSize } from './types' | ||
const colorOptions: ButtonColor[] = ['primary', 'secondary', 'link'] | ||
const colorOptions: ButtonColor[] = ['primary', 'secondary', 'outline', 'text'] | ||
const sizes: { | ||
name: string | ||
value: ButtonSize | ||
}[] = [ | ||
{ | ||
name: 'Large', | ||
value: 'lg' | ||
}, | ||
{ | ||
name: 'Medium', | ||
value: 'md' | ||
}, | ||
{ | ||
name: 'Small', | ||
value: 'sm' | ||
} | ||
] | ||
</script> | ||
|
||
<template> | ||
<Story title="BuiButton" autoPropsDisabled :layout="{ type: 'grid', width: '200px' }"> | ||
<Story title="BuiButton" autoPropsDisabled :layout="{ type: 'grid', width: '25%' }"> | ||
<Variant v-for="color in colorOptions" :title="color" :key="color"> | ||
<div class="p-4"> | ||
<div class="p-4 flex justify-center"> | ||
<BuiButton :color="color">{{ color }}</BuiButton> | ||
</div> | ||
</Variant> | ||
<h2>Disabled</h2> | ||
<Variant v-for="color in colorOptions" :title="color" :key="color"> | ||
<div class="p-4 flex justify-center"> | ||
<BuiButton :color="color" disabled>{{ color }}</BuiButton> | ||
</div> | ||
</Variant> | ||
<h2>Sizes</h2> | ||
<Variant v-for="size in sizes" :title="size.name" :key="size"> | ||
<div class="p-4 flex justify-center"> | ||
<BuiButton :size="size.value">{{ size.name }}</BuiButton> | ||
</div> | ||
</Variant> | ||
</Story> | ||
</template> | ||
|
||
<docs lang="md"> | ||
# BuiButton | ||
|
||
## Props: | ||
|
||
### color | ||
|
||
Values: `primary` | `secondary` | `text` | ||
|
||
### size | ||
|
||
Values: `lg` | `md` | `sm` | ||
</docs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,91 @@ | ||
<script setup lang="ts"> | ||
import { twMerge } from 'tailwind-merge' | ||
import { twJoin, twMerge } from 'tailwind-merge' | ||
import { computed } from 'vue-demi' | ||
import { ButtonColor } from './types.ts' | ||
const baseClasses = | ||
'focus:ring-4 focus:ring-primary-200 font-medium rounded text-sm px-5 py-2.5 mr-2 mb-2 focus:outline-none' | ||
const colorClasses: Record<ButtonColor, string> = { | ||
primary: | ||
'bg-primary-500 hover:bg-primary-550 dark:bg-primary-500 dark:hover:bg-primary-600 dark:focus:ring-primary-400 text-white', | ||
secondary: | ||
'bg-primary-150 hover:bg-primary-200 dark:bg-primary-650 dark:hover:bg-primary-700 dark:focus:ring-primary-300 text-primary-500', | ||
link: 'text-primary-500 bg-transparent hover:bg-primary-100 dark:hover:bg-primary-650 dark:hover:text-primary-400' | ||
} | ||
import type { ButtonColor, ButtonSize } from './types.ts' | ||
interface IBuiButtonProps { | ||
color: ButtonColor | ||
disabled?: boolean | ||
color?: ButtonColor | ||
size?: ButtonSize | ||
} | ||
const props = withDefaults(defineProps<IBuiButtonProps>(), { | ||
color: 'primary' | ||
disabled: false, | ||
color: 'primary', | ||
size: 'md' | ||
}) | ||
const baseClasses = 'font-medium rounded text-sm focus:outline-none' | ||
// Style Classes | ||
const primaryButtonClasses = { | ||
base: 'bg-primary-500 dark:bg-primary-500 text-white', | ||
hover: 'hover:bg-primary-550 dark:hover:bg-primary-600', | ||
focus: 'dark:focus:ring-primary-400 focus:bg-primary-575', | ||
disabled: | ||
'border-slate-300 hover:border-slate-300 bg-gray-150 dark:bg-primary-600 hover:bg-gray-150 text-gray-400 hover:text-gray-400 cursor-not-allowed' | ||
} | ||
const secondaryButtonClasses = { | ||
base: 'bg-transparent text-primary-550', | ||
hover: 'hover:bg-primary-150 dark:hover:bg-primary-650', | ||
focus: 'dark:focus:ring-primary-300 focus:bg-primary-175', | ||
disabled: 'text-primary-250 hover:bg-white cursor-not-allowed' | ||
} | ||
const textButtonClasses = { | ||
base: 'text-primary-500 dark:text-primary-225 bg-transparent', | ||
hover: 'dark:hover:text-primary-400', | ||
focus: '', | ||
disabled: | ||
'text-primary-250 dark:text-primary-175 dark:hover:text-primary-175 bg-white hover:bg-white dark:bg-transparent cursor-not-allowed' | ||
} | ||
const outlineButtonClasses = { | ||
base: 'text-primary-500 bg-transparent border border-primary-500 dark:border:primary-400 dark:text-primary-400', | ||
hover: 'hover:bg-primary-150 dark:hover:text-primary-500 dark:hover:bg-primary-650', | ||
focus: 'focus:bg-primary-175 dark:focus:bg-primary-625', | ||
disabled: | ||
'text-primary-250 border-primary-250 bg-primary-100 dark:bg-transparent hover:bg-primary-100 cursor-not-allowed dark:border-primary-590 dark:text-primary-590 dark:hover:text-primary-590' | ||
} | ||
const colorClasses: Record<ButtonColor, string> = { | ||
primary: twJoin( | ||
primaryButtonClasses.base, | ||
primaryButtonClasses.hover, | ||
primaryButtonClasses.focus, | ||
props.disabled && primaryButtonClasses.disabled | ||
), | ||
secondary: twJoin( | ||
secondaryButtonClasses.base, | ||
secondaryButtonClasses.hover, | ||
secondaryButtonClasses.focus, | ||
props.disabled && secondaryButtonClasses.disabled | ||
), | ||
text: twJoin( | ||
textButtonClasses.base, | ||
textButtonClasses.hover, | ||
textButtonClasses.focus, | ||
props.disabled && textButtonClasses.disabled | ||
), | ||
outline: twJoin( | ||
outlineButtonClasses.base, | ||
outlineButtonClasses.hover, | ||
outlineButtonClasses.focus, | ||
props.disabled && outlineButtonClasses.disabled | ||
) | ||
} | ||
const sizeClasses: Record<ButtonSize, string> = { | ||
lg: 'py-2 px-5', | ||
md: 'py-1 px-4', | ||
sm: 'py-0.5 px-4' | ||
} | ||
const buttonClasses = computed(() => { | ||
return twMerge(baseClasses, colorClasses[props.color]) | ||
return twMerge(baseClasses, colorClasses[props.color], sizeClasses[props.size]) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<button :class="buttonClasses"> | ||
<slot>Primary</slot> | ||
<button :class="buttonClasses" :disabled="disabled"> | ||
<slot name="prefix"></slot> | ||
<slot name="default">Primary</slot> | ||
<slot name="suffix"></slot> | ||
</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<button class="font-medium rounded text-sm focus:outline-none bg-primary-500 dark:bg-primary-500 text-white hover:bg-primary-550 dark:hover:bg-primary-600 dark:focus:ring-primary-400 focus:bg-primary-575 py-1 px-4">Primary</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<button class="focus:ring-4 focus:ring-primary-200 font-medium rounded text-sm focus:outline-none bg-primary-150 dark:bg-primary-650 text-primary-500 hover:bg-primary-200 dark:hover:bg-primary-700 dark:focus:ring-primary-300 py-1 px-4">Primary</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<button class="font-medium rounded text-sm focus:outline-none text-primary-500 dark:text-primary-225 bg-transparent dark:hover:text-primary-400 py-1 px-4">Primary</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export type ButtonColor = 'primary' | 'secondary' | 'link' | ||
export type ButtonColor = 'primary' | 'secondary' | 'text' | 'outline' | ||
export type ButtonSize = 'lg' | 'md' | 'sm' |
Oops, something went wrong.