Skip to content

Commit

Permalink
Improve Tabs hover state
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-leamon committed Jun 1, 2024
1 parent 3af86c6 commit 79ed992
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"version": "1.0.134",
"version": "1.0.135",
"description": "Formation is a comprehensive component library powered by React, Styled Components, and CSS variables for creating apps and websites that demand responsive, unified cross-platform experiences.",
"resolutions": {
"string-width": "^4",
Expand Down
5 changes: 4 additions & 1 deletion src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export const Button: FC<ButtonProps> = React.memo(({
hero={hero}
icon={icon}
compact={compact}
off={off}
>
{
children
Expand Down Expand Up @@ -253,6 +254,7 @@ interface TextProps {
hero?: boolean,
icon?: string,
compact?: boolean
off?: boolean
}

const calculateWidth = (props: ContainerProps) => {
Expand Down Expand Up @@ -411,12 +413,12 @@ const S = {
height: ${props => calculateHeight(props)};
max-width: ${props => calculateWidth(props)};
width: ${props => calculateWidth(props)};
opacity: ${props => props.off ? '.5' : '1'};
display: flex;
align-items: center;
a {
height: 100%;
}
`),
Text: React.memo(styled.div<TextProps>`
font-size: ${props =>
Expand All @@ -428,6 +430,7 @@ const S = {
};
display: flex;
flex-shrink: 0;
opacity: ${props => props.off ? '.5' : '1'};
`),
Button: React.memo(styled.button.attrs({
type: 'submit',
Expand Down
10 changes: 7 additions & 3 deletions src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export const Tabs = React.memo(({

const Content = () => <>
{
tabs.map(({ name, icon, onClick, prefix, suffix, iconPrefix }) =>
<Button
tabs.map(({ name, icon, onClick, prefix, suffix, iconPrefix }) => {
const active = name === localActiveTab
return <Button
key={name}
text={`${prefix ? prefix : ''}${name}${suffix ? suffix : ''}`}
icon={icon}
Expand All @@ -77,10 +78,13 @@ export const Tabs = React.memo(({
? onClick(e)
: null
}}
secondary={name !== localActiveTab}
secondary={!active}
off={!active}
tab={true}
compact={compact}
/>
}

)
}
</>
Expand Down

0 comments on commit 79ed992

Please sign in to comment.