Skip to content

Commit 317221c

Browse files
committed
feat: change color with the brand props
1 parent ec58c33 commit 317221c

File tree

11 files changed

+2616
-1962
lines changed

11 files changed

+2616
-1962
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ lerna-debug.log*
1010
node_modules
1111
dist
1212
lib
13+
!src/lib
1314
dist-ssr
1415
*.local
1516

17+
1618
# Editor directories and files
1719
.vscode/*
1820
!.vscode/extensions.json

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@radix-icons/vue": "^1.0.0",
7777
"class-variance-authority": "^0.7.0",
7878
"clsx": "^2.1.1",
79+
"colord": "^2.9.3",
7980
"radix-vue": "^1.9.7",
8081
"tailwind-merge": "^2.5.4",
8182
"tailwindcss-animate": "^1.0.7"

packages/auth/Auth.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ import { provide, ref, watch, computed } from 'vue'
7676
import { I18nVariables, en, merge } from '@supabase/auth-ui-shared'
7777
import { createStitches } from '@stitches/core'
7878
import cloneDeep from 'lodash.clonedeep'
79+
import { colord } from 'colord'
80+
import colors from 'tailwindcss/colors'
7981
8082
import '../ui/index.css'
8183
@@ -154,6 +156,19 @@ watch(
154156
{ deep: true }
155157
)
156158
159+
watch(
160+
() => props.appearance,
161+
() => {
162+
const currentColor = colors[props.appearance?.brand ?? 'emerald']['500']
163+
const hlsColor = colord(currentColor).toHsl()
164+
document.documentElement.style.setProperty(
165+
'--brand',
166+
`${hlsColor.h} ${hlsColor.s}% ${hlsColor.l}%`
167+
)
168+
},
169+
{ deep: true }
170+
)
171+
157172
watch(
158173
() => props.view,
159174
(newView) => {

packages/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { CSSProperties, InjectionKey, Ref } from 'vue'
2+
import colors from 'tailwindcss/colors'
23
import type {
34
BaseAppearance,
45
I18nVariables,
@@ -17,6 +18,7 @@ import type {
1718
} from '@supabase/supabase-js'
1819

1920
export interface Appearance extends BaseAppearance {
21+
brand: keyof typeof colors
2022
style?: {
2123
anchor?: CSSProperties
2224
button?: CSSProperties

0 commit comments

Comments
 (0)