-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch from styled-components to stitchesjs
refactor all components to make us of the stitches styling library ahead of removing styled components and styled system from the package entirely
- Loading branch information
1 parent
384246e
commit f1c973b
Showing
44 changed files
with
2,318 additions
and
1,923 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import React from 'react'; | ||
import { Story, Meta } from '@storybook/react'; | ||
import { Anchor, AnchorProps } from '.'; | ||
import React from 'react' | ||
import { Story, Meta } from '@storybook/react' | ||
import { Anchor, AnchorProps } from '.' | ||
|
||
export default { | ||
title: 'Components/Anchor', | ||
component: Anchor, | ||
args: { | ||
href: 'https://source.unsplash.com/8TQUF6UbpAk/1600x900', | ||
children: 'Click me', | ||
}, | ||
} as Meta; | ||
children: 'Click me' | ||
} | ||
} as Meta | ||
|
||
const Template: Story<AnchorProps> = args => <Anchor {...args} />; | ||
const Template: Story<AnchorProps> = (args) => <Anchor {...args} /> | ||
|
||
// Base default anchor | ||
export const Base = Template.bind({}); | ||
export const Base = Template.bind({}) | ||
|
||
// open link in new tab | ||
export const asNew = (args: AnchorProps) => <Anchor {...args} external />; | ||
export const External = (args: AnchorProps) => <Anchor {...args} external /> | ||
|
||
// link appear as Button | ||
// export const asButton = (args: AnchorProps) => <Anchor {...args} asBtn /> | ||
export const asButton = (args: AnchorProps) => <Anchor {...args} asBtn /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,60 @@ | ||
import styled, { StyledComponentProps } from 'styled-components'; | ||
import React, { FunctionComponent } from 'react'; | ||
import { color, ColorProps, compose, space, SpaceProps } from 'styled-system'; | ||
import React, { AnchorHTMLAttributes } from 'react' | ||
import { styled } from '../../stitches.config' | ||
import { Button } from '../button' | ||
|
||
type StyledAnchorProps = ColorProps & SpaceProps; | ||
|
||
type AnchorCompProps = StyledComponentProps< | ||
'button', | ||
any, | ||
StyledAnchorProps, | ||
never | ||
>; | ||
|
||
export interface AnchorProps extends AnchorCompProps { | ||
export interface AnchorProps extends AnchorHTMLAttributes<HTMLAnchorElement> { | ||
/* link content */ | ||
children: React.ReactNode; | ||
children: React.ReactNode | ||
/* Link URL */ | ||
href: string; | ||
href: string | ||
/* Use Anchor as a Button? */ | ||
// asBtn?: boolean | ||
asBtn?: boolean | ||
/* Open link in new tab? */ | ||
external?: boolean; | ||
external?: boolean | ||
} | ||
|
||
const StyledAnchor = styled.a<AnchorProps>` | ||
${compose(color, space)} | ||
text-decoration: none; | ||
color: ${({ theme }) => theme.colors.button.background}; | ||
cursor: pointer; | ||
/* visited Anchor */ | ||
&:visited { | ||
color: 'purple'; | ||
} | ||
/* mouse over Anchor */ | ||
&:hover { | ||
color: ${({ theme }) => theme.colors.button.hover}; | ||
const StyledAnchor = styled('a', { | ||
textDecoration: 'none', | ||
color: '$button_background', | ||
cursor: 'pointer', | ||
'&:visited': { | ||
color: 'purple' | ||
}, | ||
'&:hover': { | ||
color: '$button_hover' | ||
}, | ||
'&:active': { | ||
color: '$button_focus' | ||
} | ||
/* selected Anchor */ | ||
&:active { | ||
color: ${({ theme }) => theme.colors.button.focus}; | ||
} | ||
`; | ||
}) | ||
|
||
const LinkButton = styled(Button, {}) | ||
|
||
export const Anchor: FunctionComponent<AnchorProps> = ({ | ||
export const Anchor: React.FC<AnchorProps> = ({ | ||
href, | ||
children, | ||
external, | ||
asBtn | ||
}) => { | ||
if (external) { | ||
return ( | ||
<StyledAnchor href={href} target="_blank" rel="noopener noreferrer"> | ||
<StyledAnchor href={href} target='_blank' rel='noopener noreferrer'> | ||
{children} | ||
</StyledAnchor> | ||
); | ||
) | ||
} else if (asBtn) { | ||
return ( | ||
<StyledAnchor href={href}> | ||
<LinkButton>{children}</LinkButton> | ||
</StyledAnchor> | ||
) | ||
} else { | ||
return <StyledAnchor href={href}>{children}</StyledAnchor>; | ||
return <StyledAnchor href={href}>{children}</StyledAnchor> | ||
} | ||
}; | ||
} | ||
|
||
Anchor.defaultProps = { | ||
external: false, | ||
}; | ||
external: false | ||
} | ||
|
||
Anchor.displayName = 'Anchor'; | ||
Anchor.displayName = 'Anchor' |
Oops, something went wrong.