Skip to content

Commit

Permalink
fix(focus): uniform focus outline accros components
Browse files Browse the repository at this point in the history
  • Loading branch information
stafyniaksacha committed Oct 18, 2023
1 parent b078396 commit fa4c017
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/plugins/components/button-close/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default plugin.withOptions(

addComponents({
[`.${prefix}button-close`]: {
[`@apply flex h-${config.size} w-${config.size} items-center justify-center transition-colors duration-${config.duration} disabled:opacity-30 cursor-pointer`]:
[`@apply ${prefix}focus flex h-${config.size} w-${config.size} items-center justify-center transition-colors duration-${config.duration} disabled:opacity-30 cursor-pointer`]:
{},

[`.${prefix}button-icon`]: {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/components/button-icon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default plugin.withOptions(

addComponents({
[`.${prefix}button-icon`]: {
[`@apply ${prefix}focus relative inline-flex items-center justify-center space-x-1 font-sans text-${config.text} font-${config.font} leading-5 no-underline outline-none transition-all duration-${config.duration} disabled:opacity-60 disabled:cursor-not-allowed hover:shadow-none`]:
[`@apply ${prefix}focus relative inline-flex items-center justify-center space-x-1 font-sans text-${config.text} font-${config.font} leading-5 no-underline transition-all duration-${config.duration} disabled:opacity-60 disabled:cursor-not-allowed hover:shadow-none`]:
{},

[`&.${prefix}button-small`]: {
Expand Down
28 changes: 16 additions & 12 deletions src/plugins/components/checkbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,22 @@ export default plugin.withOptions(
[`@apply text-${config.error.text} ms-1 inline-block font-${config.error.font} text-${config.error.textSixe}`]:
{},
},
[`&.${prefix}checkbox-rounded .${prefix}checkbox-inner`]: {
[`@apply rounded`]: {},
},
[`&.${prefix}checkbox-smooth .${prefix}checkbox-inner`]: {
[`@apply rounded-${config.rounded.smooth}`]: {},
},
[`&.${prefix}checkbox-curved .${prefix}checkbox-inner`]: {
[`@apply rounded-${config.rounded.curved}`]: {},
},
[`&.${prefix}checkbox-full .${prefix}checkbox-inner`]: {
[`@apply rounded-${config.rounded.full}`]: {},
},
[`&.${prefix}checkbox-rounded .${prefix}checkbox-outer, &.${prefix}checkbox-rounded .${prefix}checkbox-inner`]:
{
[`@apply rounded`]: {},
},
[`&.${prefix}checkbox-smooth .${prefix}checkbox-outer, &.${prefix}checkbox-smooth .${prefix}checkbox-inner`]:
{
[`@apply rounded-${config.rounded.smooth}`]: {},
},
[`&.${prefix}checkbox-curved .${prefix}checkbox-outer, &.${prefix}checkbox-curved .${prefix}checkbox-inner`]:
{
[`@apply rounded-${config.rounded.curved}`]: {},
},
[`&.${prefix}checkbox-full .${prefix}checkbox-outer, &.${prefix}checkbox-full .${prefix}checkbox-inner`]:
{
[`@apply rounded-${config.rounded.full}`]: {},
},
[`&.${prefix}checkbox-default`]: {
[`@apply text-${config.default.text} dark:text-${config.default.textDark}`]:
{},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/components/dropdown-item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default plugin.withOptions(

addComponents({
[`.${prefix}dropdown-item`]: {
[`@apply flex w-full items-center justify-start gap-2 px-3 py-2 text-${config.textPosition} text-${config.textSize} cursor-pointer transition-colors duration-${config.duration}`]:
[`@apply ${prefix}focus flex w-full items-center justify-start gap-2 px-3 py-2 text-${config.textPosition} text-${config.textSize} cursor-pointer transition-colors duration-${config.duration}`]:
{},

[`.${prefix}item-content`]: {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/components/focus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type PluginOption, defaultPluginOptions } from '../../options'

const defaultFocusConfig = {
offset: '2',
width: '1',
width: '2',
style: 'dashed',
color: 'muted-300',
colorDark: 'muted-600',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/components/input-file-regular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default plugin.withOptions(
[`@apply relative`]: {},
},
[`.${prefix}input-file-inner`]: {
[`@apply relative ${prefix}focus flex w-${config.inner.size} cursor-pointer items-center overflow-hidden font-${config.inner.font} transition-colors duration-${config.inner.duration} focus-within:outline-1 disabled:cursor-not-allowed disabled:opacity-75`]:
[`@apply relative ${prefix}focus flex w-${config.inner.size} cursor-pointer items-center overflow-hidden font-${config.inner.font} transition-colors duration-${config.inner.duration} disabled:cursor-not-allowed disabled:opacity-75`]:
{},
},
[`.${prefix}input-file-addon`]: {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/components/input-file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default plugin.withOptions(

addComponents({
[`.${prefix}input-file`]: {
[`@apply relative block`]: {},
[`@apply relative block ${prefix}focus`]: {},

[`&.${prefix}input-file-drop`]: {
[`@apply relative h-${config.drop.size} border-dashed border-2 border-${config.drop.border} dark:border-${config.drop.borderDark} hover:border-${config.drop.borderHover} dark:hover:border-${config.drop.borderHoverDark} bg-${config.drop.bg} dark:bg-${config.drop.bgDark} flex justify-center items-center transition-colors duration-${config.drop.duration}`]:
Expand Down Expand Up @@ -155,7 +155,7 @@ export default plugin.withOptions(
{},
},
[`.${prefix}combo-input`]: {
[`@apply block w-${config.combo.input.size} text-${config.combo.input.textSize} text-${config.combo.input.text} dark:text-${config.combo.input.textDark} file:me-4 file:py-2 file:px-4 file:border-0 file:cursor-pointer file:text-${config.combo.input.textFileSize} file:transition-colors file:bg-${config.combo.input.bgFile} file:text-${config.combo.input.textFile} hover:file:bg-${config.combo.input.bgFileHover}`]:
[`@apply outline-none block w-${config.combo.input.size} text-${config.combo.input.textSize} text-${config.combo.input.text} dark:text-${config.combo.input.textDark} file:me-4 file:py-2 file:px-4 file:border-0 file:cursor-pointer file:text-${config.combo.input.textFileSize} file:transition-colors file:bg-${config.combo.input.bgFile} file:text-${config.combo.input.textFile} hover:file:bg-${config.combo.input.bgFileHover}`]:
{},
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/components/message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default plugin.withOptions(
{},
},
[`.${prefix}message-close`]: {
[`@apply ${prefix}focus text-${config.messageClose.text} me-2 ms-auto flex cursor-pointer items-center justify-center p-${config.messageClose.space} outline-none rounded-${config.messageClose.rounded} transition-colors duration-${config.messageClose.duration}`]:
[`@apply ${prefix}focus text-${config.messageClose.text} me-2 ms-auto flex cursor-pointer items-center justify-center p-${config.messageClose.space} rounded-${config.messageClose.rounded} transition-colors duration-${config.messageClose.duration}`]:
{},
[`.${prefix}close-icon`]: {
[`@apply h-${config.messageClose.iconSize} w-${config.messageClose.iconSize}`]:
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/components/snack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default plugin.withOptions(

addComponents({
[`.${prefix}snack`]: {
[`@apply ${prefix}focus inline-flex items-center gap-1 rounded-${config.rounded} outline-transparent overflow-hidden`]:
[`@apply inline-flex items-center gap-1 rounded-${config.rounded} outline-transparent`]:
{},

[`.${prefix}snack-icon`]: {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/components/snack/snack.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Snack = ({
${ButtonClose({
shape: 'full',
classes: {
wrapper: 'nui-snack-button',
wrapper: 'nui-snack-button scale-75',
},
})}
</div>
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/components/switch-ball/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ export default plugin.withOptions(
[`@apply flex cursor-pointer items-center`]: {},

[`.${prefix}switch-ball-outer`]: {
[`@apply relative block`]: {},
[`@apply ${prefix}focus relative block rounded-${config.handle.rounded}`]:
{},
},
[`.${prefix}switch-ball-handle`]: {
[`@apply border-${config.handle.border} dark:border-${config.handle.borderDark} dark:bg-${config.handle.bgDark} absolute start-0.5 top-1/2 z-10 flex h-${config.handle.size} w-${config.handle.size} -translate-y-1/2 items-center justify-center rounded-${config.handle.rounded} border bg-${config.handle.bg} shadow transition focus:w-6`]:
{},
},
[`.${prefix}switch-ball-track`]: {
[`@apply bg-${config.track.bg} dark:bg-${config.track.bgDark} block h-6 w-11 rounded-${config.track.rounded} shadow-inner outline-1 outline-transparent transition-all duration-${config.track.duration}`]:
[`@apply bg-${config.track.bg} dark:bg-${config.track.bgDark} block h-6 w-11 rounded-${config.track.rounded} shadow-inner transition-all duration-${config.track.duration}`]:
{},
},
[`.${prefix}switch-ball-icon`]: {
Expand Down Expand Up @@ -107,10 +108,6 @@ export default plugin.withOptions(
[`@apply -translate-y-1/2 translate-x-full rtl:-translate-x-full`]:
{},
},
[`&:checked ~ .${prefix}switch-ball-track`]: {
[`@apply outline-dashed outline-offset-2 ring-0 dark:outline-muted-600 outline-muted-300`]:
{},
},
[`&:checked ~ .${prefix}switch-ball-icon`]: {
[`@apply -translate-y-1/2 opacity-100`]: {},
},
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/components/switch-thin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ export default plugin.withOptions(
[`@apply flex cursor-pointer items-center`]: {},

[`.${prefix}switch-thin-outer`]: {
[`@apply relative block h-4`]: {},
[`@apply ${prefix}focus relative block h-4 rounded-${config.handle.rounded}`]:
{},
},
[`.${prefix}switch-thin-handle`]: {
[`@apply border-${config.handle.border} dark:border-${config.handle.borderDark} dark:bg-${config.handle.bgDark} absolute -start-1 top-1/2 flex h-${config.handle.size} w-${config.handle.size} -translate-y-1/2 items-center justify-center rounded-${config.handle.rounded} border bg-${config.handle.bg} shadow transition`]:
{},
},
[`.${prefix}switch-thin-track`]: {
[`@apply bg-${config.track.bg} dark:bg-${config.track.bgDark} block h-4 w-10 rounded-${config.track.rounded} shadow-inner outline-1 outline-transparent transition-all duration-${config.track.duration}`]:
[`@apply bg-${config.track.bg} dark:bg-${config.track.bgDark} block h-4 w-10 rounded-${config.track.rounded} shadow-inner transition-all duration-${config.track.duration}`]:
{},
},
[`.${prefix}switch-thin-single-label`]: {
Expand All @@ -98,10 +99,6 @@ export default plugin.withOptions(
[`@apply -translate-y-1/2 translate-x-full rtl:-translate-x-full`]:
{},
},
[`&:checked ~ .${prefix}switch-thin-track`]: {
[`@apply outline-dashed outline-offset-2 ring-0 dark:outline-muted-600 outline-muted-300`]:
{},
},
},
[`&.${prefix}switch-thin-primary .${prefix}switch-thin-input:checked ~ .${prefix}switch-thin-track`]:
{
Expand Down

0 comments on commit fa4c017

Please sign in to comment.