Skip to content

Commit

Permalink
fix #169 - Add toggle focus styles (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-dassana authored Dec 8, 2020
1 parent bc6527c commit b7b4524
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dassana-io/web-components",
"version": "0.7.6",
"version": "0.7.7",
"publishConfig": {
"registry": "https://npm.pkg.github.com/dassana-io"
},
Expand Down
18 changes: 16 additions & 2 deletions src/components/Toggle/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const togglePalette = {
primary: blacks['lighten-10'],
secondary: blacks['lighten-20']
},
focus: {
primary: blacks['lighten-10'],
secondary: blacks.base
},
inactive: {
primary: blacks['lighten-10'],
secondary: blacks['lighten-30']
Expand All @@ -26,6 +30,10 @@ const togglePalette = {
primary: blacks['lighten-80'],
secondary: grays.base
},
focus: {
primary: blacks['lighten-80'],
secondary: grays.base
},
inactive: {
primary: blacks['lighten-80'],
secondary: whites.base
Expand All @@ -34,7 +42,7 @@ const togglePalette = {
}

export const generateToggleStyles = (themeType: ThemeType) => {
const { active, inactive, disabled } = togglePalette[themeType]
const { active, inactive, focus, disabled } = togglePalette[themeType]

return {
'&.ant-switch': {
Expand All @@ -54,6 +62,9 @@ export const generateToggleStyles = (themeType: ThemeType) => {
},
left: 'calc(100% - 18px - 2px)'
},
'&:focus': {
boxShadow: `0 0 0 3px ${focus.primary}`
},
backgroundColor: active.primary
},
'&.ant-switch-disabled': {
Expand All @@ -76,7 +87,10 @@ export const generateToggleStyles = (themeType: ThemeType) => {
}
},
'&:focus': {
boxShadow: 'none'
'&:hover': {
boxShadow: `0 0 0 3px ${focus.secondary}`
},
boxShadow: `0 0 0 3px ${focus.secondary}`
},
backgroundColor: inactive.primary
}
Expand Down

0 comments on commit b7b4524

Please sign in to comment.