Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Button = ({
case 'fill':
props.bg = brand ? theme.brandColors[brand] : bg
props.text = brand ? theme.textColors.on[brand] : text
props['bg-hover'] = getColorShade(
props['bg-hocus'] = getColorShade(
brand ? theme.brandColors[brand] : bg,
theme.highlightOffset,
)
Expand All @@ -48,22 +48,23 @@ const Button = ({
// eslint-disable-next-line react/prop-types
props.border.push(brand ? theme.brandColors[brand] : border)
props.text = brand ? theme.brandColors[brand] : border
props['bg-hover'] = brand ? theme.brandColors[brand] : border
props['text-hover'] = brand ? theme.textColors.on[brand] : text
props['bg-hocus'] = brand ? theme.brandColors[brand] : border
props['text-hocus'] = brand ? theme.textColors.on[brand] : text
break
case 'text':
props.text = brand ? theme.brandColors[brand] : text
props['bg-hover'] = `${getColorShade(
props['bg-hocus'] = `${getColorShade(
brand ? theme.brandColors[brand] : text,
'lightest',
)}`
break
case 'link':
props.leading = undefined
props.rounded = undefined
props.leading = 'normal'
props.p = 0
props.underline = true
props.text = brand ? theme.brandColors[brand] : text
props['text-hover'] = getColorShade(
props['text-hocus'] = getColorShade(
brand ? theme.brandColors[brand] : text,
theme.highlightOffset,
)
Expand Down
2 changes: 1 addition & 1 deletion src/button/__tests__/__snapshots__/Button.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Button renders matching snapshot 1`] = `
<BaseComponent
bg="blue"
bg-hover="blue-dark"
bg-hocus="blue-dark"
border={
Array [
true,
Expand Down
2 changes: 0 additions & 2 deletions src/form/TextInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const TextInput = ({
border={!isInvalid ? true : [true, theme.brandColors.danger]}
w="full"
leading="tight"
outline-focus="none"
shadow-focus="outline"
opacity={disabled ? 50 : undefined}
id={field.inputId || id || name}
name={name}
Expand Down
2 changes: 0 additions & 2 deletions src/form/__tests__/__snapshots__/TextInput.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ exports[`TextInput renders matching snapshot 1`] = `
}
}
name="username"
outline-focus="none"
p={
Object {
"x": 4,
Expand All @@ -24,7 +23,6 @@ exports[`TextInput renders matching snapshot 1`] = `
}
readOnly={false}
rounded="rounded"
shadow-focus="outline"
text="grey-darkest"
type="text"
w="full"
Expand Down
4 changes: 2 additions & 2 deletions src/header/NavItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const NavItem = ({
<BaseComponent
is={is}
text={style.text}
bg-hover={style.text}
text-hover={style.bg}
bg-hocus={style.text}
text-hocus={style.bg}
p={{ x: theme.spacing.md, y: theme.spacing.sm }}
m={{ t: theme.spacing.sm }}
m-lg={{ t: 0, r: theme.spacing.sm }}
Expand Down
4 changes: 2 additions & 2 deletions src/header/__tests__/__snapshots__/NavItem.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`NavItem renders matching snapshot 1`] = `
<BaseComponent
bg-hover="white"
bg-hocus="white"
className="block no-underline"
is={[Function]}
m={
Expand All @@ -24,7 +24,7 @@ exports[`NavItem renders matching snapshot 1`] = `
}
rounded="rounded"
text="white"
text-hover="blue"
text-hocus="blue"
>
Link
</BaseComponent>
Expand Down
4 changes: 2 additions & 2 deletions src/header/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Example:
<NavItem is={props => <a {...props} href="#header" />}>Docs</NavItem>
<NavItem is={props => <a {...props} href="#header" />}>Examples</NavItem>
<NavItem is={props => <a {...props} href="#header" />}>Blog</NavItem>
<OutlineButton border="white" text="white" text-hover="blue">
<OutlineButton border="white" text="white" text-hocus="blue">
Download
</OutlineButton>
</NavMenu>
Expand Down Expand Up @@ -47,7 +47,7 @@ Custom branding example:
<NavItem is={props => <a {...props} href="#header" />}>Docs</NavItem>
<NavItem is={props => <a {...props} href="#header" />}>Examples</NavItem>
<NavItem is={props => <a {...props} href="#header" />}>Blog</NavItem>
<OutlineButton border="white" text="white" text-hover="purple">
<OutlineButton border="white" text="white" text-hocus="purple">
Download
</OutlineButton>
</NavMenu>
Expand Down
9 changes: 8 additions & 1 deletion src/tailwind/BaseComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ const BaseComponent = ({ is, children, className, ...rest }) => {
return (
<Component
{...filterProps(rest, tailwindProps)}
className={classnames(getTailwindClassNames(rest), className)}
className={classnames(
getTailwindClassNames({
'outline-focus': 'none',
'shadow-focus': 'outline',
...rest,
}),
className,
)}
>
{children}
</Component>
Expand Down
8 changes: 8 additions & 0 deletions src/tailwind/getTailwindClassNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ export default (props, { ignore = [] } = {}) =>
if (!tailwindProps.includes(type)) return twClasses

if (tailwindVariants.includes(variant)) {
if (variant === 'hocus') {
return [
...twClasses,
tailwindPropToClassName(`hover:${type}`, props[key]),
tailwindPropToClassName(`focus:${type}`, props[key]),
]
}

return [
...twClasses,
tailwindPropToClassName(`${variant}:${type}`, props[key]),
Expand Down
2 changes: 1 addition & 1 deletion src/tailwind/tailwindProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const propTypes = {
whitespace: PropTypes.string,
}

export const variants = ['hover', 'focus', 'sm', 'md', 'lg', 'xl']
export const variants = ['hover', 'focus', 'hocus', 'sm', 'md', 'lg', 'xl']

export default [
...Object.keys(propTypes),
Expand Down