Skip to content

Commit

Permalink
feat: button
Browse files Browse the repository at this point in the history
  • Loading branch information
JasKang committed Oct 13, 2023
1 parent 1c1d2af commit b21ad35
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 150 deletions.
45 changes: 0 additions & 45 deletions src/_utils/style.ts

This file was deleted.

78 changes: 0 additions & 78 deletions src/_utils/tw.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react'

import type { Color } from '../../_utils/colors'
import type { Color } from '@/utils/colors'
import { LoadingIcon } from '../Icon/LoadingIcon'
import { style } from './style'

Expand Down Expand Up @@ -42,7 +42,7 @@ export function Button(props: ButtonProps) {
<button className={css} style={vars} type="button" disabled={disabled}>
{(icon || loading) && (
<i className="h-[1em] w-[1em] scale-125 [&_+_span]:ml-1.5 [&_svg]:h-full [&_svg]:w-full">
{loading ? <LoadingIcon class="animate-spin" /> : icon}
{loading ? <LoadingIcon className="animate-spin" /> : icon}
</i>
)}
{children && <span className="inline-flex items-center">{children}</span>}
Expand Down
8 changes: 4 additions & 4 deletions src/components/Icon/LoadingIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


export const LoadingIcon = ()=>{
return () => (
export function LoadingIcon (){
return (
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle
opacity="0.25"
Expand All @@ -10,12 +10,12 @@ export const LoadingIcon = ()=>{
r="10"
stroke="currentColor"
stroke-width="4"
></circle>
/>
<path
opacity="0.75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
></path>
/>
</svg>
)
}
File renamed without changes.
23 changes: 3 additions & 20 deletions src/utils/style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Flat, isFunction } from 'kotl'
import { type Flat } from 'kotl'

import { type ColorVar } from '@/theme/colors'
import { type ColorVar } from './colors'

export type StyleVars<N extends string, T extends string> = {
[k in `--${N}-${T}`]: string
Expand All @@ -15,7 +15,7 @@ export function createStyleVar<N extends string, T extends CssVars>(name: N) {
const result = Object.entries(cssVars).reduce(
(acc, [key, value]) => {
const colorVal = cvar(value)
// @ts-ignore
// @ts-expect-error
acc[`--${name}-${key}`] = colorVal || value
return acc
},
Expand All @@ -25,23 +25,6 @@ export function createStyleVar<N extends string, T extends CssVars>(name: N) {
}
}

export function useColorVars<N extends string, T extends { [key: string]: ColorVar }>(
name: N,
getter: MaybeRefOrGetter<T>
) {
return computed(() =>
Object.entries(toValue(getter)).reduce(
(acc, [key, val]) => {
const colorVal = cvar(val)
// @ts-ignore
acc[`--${name}-${key}`] = colorVal || value
return acc
},
{} as Record<string, string>
)
)
}

export function createColorVars(name: string, getter: Record<string, ColorVar>) {
return Object.entries(getter).reduce(
(acc, [key, val]) => {
Expand Down
1 change: 0 additions & 1 deletion src/utils/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export function tw<T extends VariantsObject>(
clsValue[1].split(' ').forEach(c => {
const index = cls.indexOf(c.trim())
if (index !== -1) {
console.log('remove', c)
cls.splice(index, 1)
}
})
Expand Down

0 comments on commit b21ad35

Please sign in to comment.