-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): add Link component (#51)
* feat(component): add link component add a new Link component to add links to email resolves #43 Signed-off-by: Niloy Sikdar <niloysikdar30@gmail.com> * docs(storybook): link stories add stories for Link component resolves #43 Signed-off-by: Niloy Sikdar <niloysikdar30@gmail.com> * fix(component): fix Link component fix Link component with the updated structure and props resolves #43 Signed-off-by: Niloy Sikdar <niloysikdar30@gmail.com>
- Loading branch information
1 parent
3c2015c
commit 71390e7
Showing
5 changed files
with
69 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { Button } from './Button'; | ||
export { Button, ButtonProps } from './Button'; |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
|
||
import { Email } from '../Email/Email'; | ||
import { Section } from '../Section/Section'; | ||
import { Column } from '../Column/Column'; | ||
import { Link } from './Link'; | ||
|
||
export default { | ||
component: Link, | ||
} as ComponentMeta<typeof Link>; | ||
|
||
//“template” of how args map to rendering | ||
const Template: ComponentStory<typeof Link> = (args) => ( | ||
<Email> | ||
<Section> | ||
<Column> | ||
<h2> | ||
Please <Link {...args} /> to access | ||
</h2> | ||
</Column> | ||
</Section> | ||
</Email> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
|
||
Default.args = { | ||
children: 'Click here', | ||
href: 'https://github.com/leopardslab/react-email', | ||
classes: { | ||
root: { | ||
color: 'red', | ||
}, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ReactNode, HTMLAttributeAnchorTarget } from 'react'; | ||
import { BaseStyleProp } from '../types'; | ||
import { makeStyles } from '../../utils/makeStyles'; | ||
|
||
type LinkStyles = 'root'; | ||
|
||
export interface LinkProps extends BaseStyleProp<LinkStyles> { | ||
children?: ReactNode; | ||
href: string; | ||
target?: HTMLAttributeAnchorTarget; | ||
} | ||
|
||
const useStyles = makeStyles({ | ||
root: {}, | ||
}); | ||
|
||
export const Link = ({ | ||
children, | ||
href, | ||
target = '_blank', | ||
classes, | ||
className, | ||
}: LinkProps): JSX.Element => { | ||
const styles = useStyles({ classes }); | ||
|
||
return ( | ||
<a href={href} target={target} style={styles.root} className={className}> | ||
{children} | ||
</a> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Link, LinkProps } from './Link'; |
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