@pluralsight/headless-styles
Advanced tools
Comparing version 0.0.0-alpha-08c739 to 0.0.0-alpha-0ec69e
import { psBackground, psBackgroundActive, psBackgroundHover, psBackgroundWeak, psNeutralBackground, psNeutralBackgroundActive, psNeutralBackgroundHover, psNeutralText, psNeutralTextWeak, psText, psTextMedium, } from '@pluralsight/design-tokens'; | ||
import { getDefaultOptions } from './shared'; | ||
const BASE_FONT_SIZE = '16px'; | ||
import styles from './generated/buttonCSS.module'; | ||
// TODO: | ||
// 1. Figure out how to convert JSObject to style-string | ||
// 2. Figure out how to make :active more important than :hover in JS Object | ||
const baseStyles = { | ||
js: { | ||
appearance: 'none', | ||
backgroundColor: 'transparent', | ||
border: 'none', | ||
borderRadius: '6px', | ||
cursor: 'pointer', | ||
fontFamily: 'PS TT Commons Roman, Gotham SSm A, Gotham SSm B, Arial,sans-serif', | ||
fontSize: BASE_FONT_SIZE, | ||
fontWeight: 'inherit', | ||
height: 'initial', | ||
outlineOffset: 'initial', | ||
padding: '10px 16px', | ||
textAlign: 'center', | ||
textDecoration: 'none', | ||
textTransform: 'none', | ||
transition: 'background-color 250ms ease-in-out, color 250ms ease-in-out', | ||
'&:active': { | ||
outline: 'none', | ||
}, | ||
'&:focus': { | ||
js: Object.assign(Object.assign({}, styles.base), { '&:focus': { | ||
outline: `3px solid ${psBackgroundActive}`, | ||
}, | ||
'&:focus:not(:focus-visible)': { | ||
boxShadow: 'none', | ||
outline: 'none', | ||
}, | ||
}, | ||
} }), | ||
css: ` | ||
appearance: none; | ||
background-color: transparent; | ||
border: none; | ||
border-radius: 6px; | ||
cursor: pointer; | ||
font-family: 'PS TT Commons Roman', 'Gotham SSm A', 'Gotham SSm B', Arial, | ||
sans-serif; | ||
font-weight: inherit; | ||
height: initial; | ||
outline-offset: initial; | ||
text-align: center; | ||
text-decoration: none; | ||
text-transform: none; | ||
transition: background-color 250ms ease-in-out, color 250ms ease-in-out; | ||
&:active { | ||
align-items: center; | ||
appearance: none; | ||
border: none; | ||
border-radius: 6px; | ||
cursor: pointer; | ||
display: inline-flex; | ||
font-family: 'PS TT Commons Roman', 'Gotham SSm A', 'Gotham SSm B', Arial, | ||
sans-serif; | ||
font-variation-settings: 'wght' 600; | ||
font-weight: 600; | ||
justify-content: center; | ||
outline: none; | ||
} | ||
&:focus { | ||
outline: 3px solid ${psBackgroundActive}; | ||
} | ||
&:focus:not(:focus-visible) { | ||
box-shadow: none; | ||
outline: none; | ||
} | ||
position: relative; | ||
text-align: center; | ||
text-decoration: none; | ||
text-transform: none; | ||
transition: background-color 250ms ease-in-out, color 250ms ease-in-out; | ||
user-select: none; | ||
vertical-align: middle; | ||
white-space: nowrap; | ||
`, | ||
@@ -65,7 +39,11 @@ }; | ||
css: ` | ||
background-color: transparent; | ||
color: ${psTextMedium}; | ||
`, | ||
js: { | ||
color: psTextMedium, | ||
}, | ||
js: Object.assign(Object.assign({}, styles.text_weak), { color: psTextMedium, '&:active': { | ||
backgroundColor: psBackgroundActive, | ||
}, '&:hover': { | ||
backgroundColor: psBackgroundHover, | ||
color: '#fff', | ||
} }), | ||
}; | ||
@@ -78,6 +56,7 @@ case 'weak': | ||
`, | ||
js: { | ||
backgroundColor: `${psNeutralBackground}`, | ||
color: psNeutralText, | ||
}, | ||
js: Object.assign(Object.assign({}, styles.weak), { backgroundColor: psNeutralBackground, color: psNeutralText, '&:active': { | ||
backgroundColor: psNeutralBackgroundActive, | ||
}, '&:hover': { | ||
backgroundColor: psNeutralBackgroundHover, | ||
} }), | ||
}; | ||
@@ -90,6 +69,7 @@ case 'medium': | ||
`, | ||
js: { | ||
backgroundColor: `${psBackground}`, | ||
color: '#fff', | ||
}, | ||
js: Object.assign(Object.assign({}, styles.medium), { backgroundColor: psBackground, '&:active': { | ||
backgroundColor: psBackgroundActive, | ||
}, '&:hover': { | ||
backgroundColor: psBackgroundHover, | ||
} }), | ||
}; | ||
@@ -102,6 +82,7 @@ case 'strong': | ||
`, | ||
js: { | ||
backgroundColor: `${psBackgroundWeak}`, | ||
color: psText, | ||
}, | ||
js: Object.assign(Object.assign({}, styles.strong), { backgroundColor: psBackgroundWeak, color: psText, '&:active': { | ||
backgroundColor: psBackgroundActive, | ||
}, '&:hover': { | ||
backgroundColor: psBackgroundHover, | ||
} }), | ||
}; | ||
@@ -111,7 +92,10 @@ default: | ||
css: ` | ||
background-color: transparent; | ||
color: ${psNeutralTextWeak}; | ||
`, | ||
js: { | ||
color: psNeutralTextWeak, | ||
}, | ||
js: Object.assign(Object.assign({}, styles.text), { color: psNeutralTextWeak, '&:active': { | ||
backgroundColor: psBackgroundActive, | ||
}, '&:hover': { | ||
backgroundColor: psNeutralBackgroundHover, | ||
} }), | ||
}; | ||
@@ -123,45 +107,25 @@ } | ||
case 'xs': | ||
return { | ||
css: ` | ||
font-size: 12px; | ||
padding: 4px 8px; | ||
`, | ||
js: { | ||
fontSize: '12px', | ||
padding: '4px 8px', | ||
}, | ||
}; | ||
return ` | ||
font-size: 0.75rem; | ||
height: 1.5rem; | ||
padding-inline: 8px; | ||
`; | ||
case 's': | ||
return { | ||
css: ` | ||
font-size: 14px; | ||
padding: 6px 12px; | ||
`, | ||
js: { | ||
fontSize: '14px', | ||
padding: '6px 12px', | ||
}, | ||
}; | ||
return ` | ||
font-size: 0.875rem; | ||
height: 2rem; | ||
padding-inline: 12px; | ||
`; | ||
case 'l': | ||
return { | ||
css: ` | ||
font-size: 16px; | ||
padding: 14.5px 24px; | ||
`, | ||
js: { | ||
fontSize: BASE_FONT_SIZE, | ||
padding: '14.5px 24px', | ||
}, | ||
}; | ||
return ` | ||
font-size: 1rem; | ||
height: 3rem; | ||
padding-inline: 24px; | ||
`; | ||
default: | ||
return { | ||
css: ` | ||
font-size: 16px; | ||
padding: 10px 16px; | ||
`, | ||
js: { | ||
fontSize: BASE_FONT_SIZE, | ||
padding: '10px 16px', | ||
}, | ||
}; | ||
return ` | ||
font-size: 1rem; | ||
height: 2.5rem; | ||
padding-inline: 16px; | ||
`; | ||
} | ||
@@ -174,64 +138,31 @@ } | ||
case 'strong': | ||
return { | ||
css: ` | ||
&:hover { | ||
color: #fff; | ||
background-color: ${psBackgroundHover}; | ||
} | ||
&:active { | ||
background-color: ${psBackgroundActive}; | ||
} | ||
`, | ||
js: { | ||
hover: { | ||
color: '#fff', | ||
backgroundColor: psBackgroundHover, | ||
}, | ||
active: { | ||
backgroundColor: `${psBackgroundActive}`, | ||
}, | ||
}, | ||
}; | ||
return ` | ||
&:hover { | ||
color: #fff; | ||
background-color: ${psBackgroundHover}; | ||
} | ||
&:active { | ||
background-color: ${psBackgroundActive}; | ||
} | ||
`; | ||
case 'weak': | ||
return { | ||
css: ` | ||
&:hover { | ||
color: #fff; | ||
background-color: ${psNeutralBackgroundHover}; | ||
} | ||
&:active { | ||
background-color: ${psNeutralBackgroundActive}; | ||
} | ||
`, | ||
js: { | ||
hover: { | ||
color: '#fff', | ||
backgroundColor: psNeutralBackgroundHover, | ||
}, | ||
active: { | ||
backgroundColor: `${psNeutralBackgroundActive}`, | ||
}, | ||
}, | ||
}; | ||
return ` | ||
&:hover { | ||
color: #fff; | ||
background-color: ${psNeutralBackgroundHover}; | ||
} | ||
&:active { | ||
background-color: ${psNeutralBackgroundActive}; | ||
} | ||
`; | ||
default: | ||
return { | ||
css: ` | ||
&:hover { | ||
color: #fff; | ||
background-color: ${psNeutralBackgroundHover}; | ||
} | ||
&:active { | ||
background-color: ${psBackgroundActive}; | ||
} | ||
`, | ||
js: { | ||
hover: { | ||
color: '#fff', | ||
backgroundColor: psNeutralBackgroundHover, | ||
}, | ||
active: { | ||
backgroundColor: `${psBackgroundActive}`, | ||
}, | ||
}, | ||
}; | ||
return ` | ||
&:hover { | ||
color: #fff; | ||
background-color: ${psNeutralBackgroundHover}; | ||
} | ||
&:active { | ||
background-color: ${psBackgroundActive}; | ||
} | ||
`; | ||
} | ||
@@ -242,4 +173,3 @@ } | ||
const kindStyles = getKindStyles(kind); | ||
const sizeStyles = getSizeStyles(size); | ||
const psuedoStyles = getPsuedoStyles(kind); | ||
const sizeKey = `size_${size}`; | ||
return { | ||
@@ -249,10 +179,10 @@ cssProps: ` | ||
${kindStyles.css.trim()} | ||
${sizeStyles.css.trim()} | ||
${psuedoStyles.css.trim()} | ||
${getSizeStyles(size).trim()} | ||
${getPsuedoStyles(kind).trim()} | ||
` | ||
.trim() | ||
.replace(/^ {2,12}/gm, ''), | ||
styles: Object.assign(Object.assign(Object.assign(Object.assign({}, baseStyles.js), kindStyles.js), sizeStyles.js), { '&:hover': Object.assign({}, psuedoStyles.js.hover), '&:active': Object.assign(Object.assign({}, baseStyles.js['&:active']), psuedoStyles.js.active) }), | ||
styles: Object.assign(Object.assign(Object.assign(Object.assign({}, baseStyles.js), kindStyles.js), styles[sizeKey]), { '&:active': Object.assign(Object.assign({}, baseStyles.js['&:active']), kindStyles.js['&:active']) }), | ||
type: 'button', | ||
}; | ||
} |
{ | ||
"name": "@pluralsight/headless-styles", | ||
"version": "0.0.0-alpha-08c739", | ||
"version": "0.0.0-alpha-0ec69e", | ||
"description": "Headless styles for Pluralsight.", | ||
"main": "./build/index.js", | ||
"main": "build/common/index.js", | ||
"module": "build/index.js", | ||
"types": "build/index.d.ts", | ||
"files": [ | ||
@@ -13,4 +15,9 @@ "build/**/*" | ||
], | ||
"workspaces": [ | ||
"sandbox" | ||
], | ||
"scripts": { | ||
"build": "yarn copy:css && tsc --project tsconfig.build.json", | ||
"build": "yarn build:common && yarn build:es", | ||
"build:common": "tsc --project tsconfig.cjs.json", | ||
"build:es": "yarn copy:css && tsc --project tsconfig.build.json", | ||
"copy:css": "copyfiles --up 1 ./src/**/*.module.css build", | ||
@@ -17,0 +24,0 @@ "test": "echo \"'yarn test' should be run from root directory.\" && exit 1" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186504
27
6806
1