-
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.
[n/a] Moving to theme colors vars (#89)
* [n/a] Making the accent color dynamic * [n/a] Updating colors to be gray * [n/a] Adding info about typography * [n/a] Fixing var in button.js
- Loading branch information
1 parent
e41e9c9
commit a7ed555
Showing
8 changed files
with
151 additions
and
104 deletions.
There are no files selected for viewing
192 changes: 99 additions & 93 deletions
192
wp-content/themes/wp-starter/plugins-tailwind/buttons.js
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,108 +1,114 @@ | ||
const plugin = require("tailwindcss/plugin") | ||
|
||
module.exports = plugin(({ addComponents }) => { | ||
// Base Styles | ||
const base = { | ||
// core | ||
'@apply inline-flex items-center rounded transition text-base gap-12': | ||
{}, | ||
// focus | ||
'@apply focus:outline-none focus-visible:ring-4': {}, | ||
// disabled | ||
'@apply disabled:opacity-20 disabled:pointer-events-none': {}, | ||
// icon | ||
'& svg': { | ||
'@apply size-20': {}, | ||
}, | ||
// text exempt | ||
'&:not(.btn-text)': { | ||
'@apply px-20 min-h-40': {}, | ||
}, | ||
} | ||
module.exports = plugin.withOptions(function (options = {}) { | ||
return function({ addComponents }) { | ||
const accentColor = options.accentColor ?? 'sky' | ||
|
||
const buttons = { | ||
// Button Variants | ||
'.btn-contained': { | ||
...base, | ||
[`@apply | ||
bg-sky-700 text-white | ||
hover:bg-sky-700 | ||
active:bg-sky-800 | ||
focus-visible:bg-sky-700 focus-visible:ring-sky-600/50`]: {}, | ||
}, | ||
// Base Styles | ||
const base = { | ||
// core | ||
'@apply inline-flex items-center rounded transition text-base gap-12': | ||
{}, | ||
// focus | ||
'@apply focus:outline-none focus-visible:ring-4': {}, | ||
// disabled | ||
'@apply disabled:opacity-20 disabled:pointer-events-none': {}, | ||
// icon | ||
'& svg': { | ||
'@apply size-20': {}, | ||
}, | ||
// text exempt | ||
'&:not(.btn-text)': { | ||
'@apply px-20 min-h-40': {}, | ||
}, | ||
} | ||
|
||
'.btn-contained-light': { | ||
...base, | ||
[`@apply | ||
bg-sky-200 text-sky-900 | ||
hover:bg-sky-50 | ||
active:bg-sky-100 | ||
focus-visible:bg-sky-50 focus-visible:ring-white/50`]: {}, | ||
}, | ||
const buttons = { | ||
// Button Variants | ||
'.btn-contained': { | ||
...base, | ||
[`@apply | ||
bg-${accentColor}-700 text-white | ||
hover:bg-${accentColor}-700 | ||
active:bg-${accentColor}-800 | ||
focus-visible:bg-${accentColor}-700 focus-visible:ring-${accentColor}-600/50`]: {}, | ||
}, | ||
|
||
'.btn-outlined': { | ||
...base, | ||
[`@apply | ||
border border-sky-900 bg-transparent text-sky-900 | ||
hover:bg-sky-100 hover:border-sky-700 hover:text-sky-700 | ||
active:bg-sky-200/80 active:text-sky-800 | ||
focus-visible:bg-sky-100 focus-visible:border-sky-700 focus-visible:ring-sky-600/50`]: {}, | ||
}, | ||
'.btn-contained-light': { | ||
...base, | ||
[`@apply | ||
bg-${accentColor}-200 text-${accentColor}-900 | ||
hover:bg-${accentColor}-50 | ||
active:bg-${accentColor}-100 | ||
focus-visible:bg-${accentColor}-50 focus-visible:ring-white/50`]: {}, | ||
}, | ||
|
||
'.btn-outlined-light': { | ||
...base, | ||
[`@apply | ||
border-white text-white | ||
hover:bg-white/25 | ||
active:bg-white/30 | ||
focus-visible:bg-sky-100/30 focus-visible:ring-white/50`]: {}, | ||
}, | ||
'.btn-outlined': { | ||
...base, | ||
[`@apply | ||
border border-${accentColor}-900 bg-transparent text-${accentColor}-900 | ||
hover:bg-${accentColor}-100 hover:border-${accentColor}-700 hover:text-${accentColor}-700 | ||
active:bg-${accentColor}-200/80 active:text-${accentColor}-800 | ||
focus-visible:bg-${accentColor}-100 focus-visible:border-${accentColor}-700 focus-visible:ring-${accentColor}-600/50`]: {}, | ||
}, | ||
|
||
'.btn-subtle': { | ||
...base, | ||
[`@apply | ||
bg-transparent bg-transparent text-sky-600 | ||
hover:bg-sky-100 hover:text-sky-700 | ||
active:bg-sky-200/80 active:text-sky-800 | ||
focus-visible:bg-sky-100 focus-visible:border-sky-700 focus-visible:ring-sky-600/50`]: {}, | ||
}, | ||
'.btn-outlined-light': { | ||
...base, | ||
[`@apply | ||
border-white text-white | ||
hover:bg-white/25 | ||
active:bg-white/30 | ||
focus-visible:bg-${accentColor}-100/30 focus-visible:ring-white/50`]: {}, | ||
}, | ||
|
||
'.btn-text': { | ||
...base, | ||
[`@apply | ||
bg-transparent text-sky-600 | ||
hover:text-sky-700 hover:underline | ||
active:text-sky-800 | ||
focus-visible:bg-sky-100 focus-visible:ring-sky-600/50`]: | ||
{}, | ||
}, | ||
'.btn-subtle': { | ||
...base, | ||
[`@apply | ||
bg-transparent bg-transparent text-${accentColor}-600 | ||
hover:bg-${accentColor}-100 hover:text-${accentColor}-700 | ||
active:bg-${accentColor}-200/80 active:text-${accentColor}-800 | ||
focus-visible:bg-${accentColor}-100 focus-visible:border-${accentColor}-700 focus-visible:ring-${accentColor}-600/50`]: {}, | ||
}, | ||
|
||
// Button Sizes | ||
'.btn-sm': { | ||
'@apply text-sm gap-8': {}, | ||
'& svg': { | ||
'@apply size-16': {}, | ||
'.btn-text': { | ||
...base, | ||
[`@apply | ||
bg-transparent text-${accentColor}-600 | ||
hover:text-${accentColor}-700 hover:underline | ||
active:text-${accentColor}-800 | ||
focus-visible:bg-${accentColor}-100 focus-visible:ring-${accentColor}-600/50`]: | ||
{}, | ||
}, | ||
'&:not(.btn-text)': { | ||
'@apply px-16 min-h-32': {}, | ||
|
||
// Button Sizes | ||
'.btn-sm': { | ||
'@apply text-sm gap-8': {}, | ||
'& svg': { | ||
'@apply size-16': {}, | ||
}, | ||
'&:not(.btn-text)': { | ||
'@apply px-16 min-h-32': {}, | ||
}, | ||
}, | ||
}, | ||
'.btn-lg': { | ||
'@apply text-xl gap-12': {}, | ||
'& svg': { | ||
'@apply size-24': {}, | ||
'.btn-lg': { | ||
'@apply text-xl gap-12': {}, | ||
'& svg': { | ||
'@apply size-24': {}, | ||
}, | ||
'&:not(.btn-text)': { | ||
'@apply px-32 min-h-56': {}, | ||
}, | ||
}, | ||
'&:not(.btn-text)': { | ||
'@apply px-32 min-h-56': {}, | ||
|
||
// Button Icon/Sizes | ||
'.btn-icon': { | ||
fontSize: '0 !important', | ||
lineHeight: '0 !important', | ||
'@apply !p-0 !gap-0 aspect-square justify-center items-center': {}, | ||
}, | ||
}, | ||
} | ||
|
||
// Button Icon/Sizes | ||
'.btn-icon': { | ||
fontSize: '0 !important', | ||
lineHeight: '0 !important', | ||
'@apply !p-0 !gap-0 aspect-square justify-center items-center': {}, | ||
}, | ||
} | ||
addComponents(buttons) | ||
addComponents(buttons) | ||
} | ||
}) | ||
|
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
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
Oops, something went wrong.