-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): Callout component (#25)
* feat(website): initial callout component * feat(website): callout colors and examples * fix(website): callout title component, use box for callout * fix(website): fix callout linting errors * fix(website): more callout lint fixing * fix(website): change callout to use calloutcontent component * fix(website): change to use token * fix(website): change CalloutContent to CalloutText * fix(tokens): add status border tokens * fix(website): callout use border tokens, pass margin props * fix(tokens): sg border token overrides
- Loading branch information
1 parent
878d3c5
commit e4a3d00
Showing
6 changed files
with
152 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
import {Text} from '@twilio-paste/text'; | ||
import {StyledCallout} from './styles'; | ||
import {CalloutProps, CalloutTitleProps, CalloutTextProps} from './types'; | ||
|
||
const CalloutTitle: React.FC<CalloutTitleProps> = ({as, children}) => ( | ||
<Text as={as} marginBottom="space40" fontSize="fontSize20"> | ||
{children} | ||
</Text> | ||
); | ||
|
||
const CalloutText: React.FC<CalloutTextProps> = ({as, children, marginTop, marginBottom}) => ( | ||
<Text as={as} marginTop={marginTop} marginBottom={marginBottom} fontSize="fontSize20"> | ||
{children} | ||
</Text> | ||
); | ||
|
||
const Callout: React.FC<CalloutProps> = props => { | ||
return ( | ||
<StyledCallout | ||
marginTop="space60" | ||
marginBottom="space60" | ||
paddingTop="space40" | ||
paddingRight="space60" | ||
paddingBottom="space40" | ||
paddingLeft="space60" | ||
variant={props.variant} | ||
> | ||
{props.children} | ||
</StyledCallout> | ||
); | ||
}; | ||
|
||
Callout.defaultProps = { | ||
variant: 'primary', | ||
}; | ||
|
||
export {Callout, CalloutTitle, CalloutText}; |
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,43 @@ | ||
import styled from '@emotion/styled'; | ||
import {themeGet} from 'styled-system'; | ||
import {Box} from '@twilio-paste/box'; | ||
import {CalloutProps} from './types'; | ||
|
||
const borderColorPartial = ({variant}: CalloutProps): string => { | ||
if (variant === 'secondary') { | ||
return themeGet('borderColors.colorBorderPrimaryDark'); | ||
} | ||
if (variant === 'warning') { | ||
return themeGet('borderColors.colorBorderWarning'); | ||
} | ||
return themeGet('borderColors.colorBorderPrimaryLight'); | ||
}; | ||
|
||
const backgroundColorPartial = ({variant}: CalloutProps): string => { | ||
if (variant === 'secondary') { | ||
return themeGet('backgroundColors.colorBackgroundPrimaryDark'); | ||
} | ||
if (variant === 'warning') { | ||
return themeGet('backgroundColors.colorBackgroundWarning'); | ||
} | ||
return themeGet('backgroundColors.colorBackgroundPrimaryLight'); | ||
}; | ||
|
||
export const StyledCallout: React.FC<CalloutProps> = styled(Box)` | ||
position: relative; | ||
border-width: ${themeGet('borderWidths.borderWidth20')}; | ||
border-style: solid; | ||
border-color: ${borderColorPartial}; | ||
border-radius: 0 ${themeGet('radii.borderRadius20')} ${themeGet('radii.borderRadius20')} 0; | ||
&::before { | ||
position: absolute; | ||
top: -2px; | ||
bottom: -2px; | ||
left: -2px; | ||
display: block; | ||
content: ''; | ||
width: ${themeGet('space.space30')}; | ||
background-color: ${backgroundColorPartial}; | ||
} | ||
`; |
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,22 @@ | ||
export type CalloutVariants = 'primary' | 'secondary' | 'warning'; | ||
|
||
export interface CalloutTitleProps { | ||
as?: string; | ||
} | ||
|
||
export interface CalloutTextProps { | ||
as?: string; | ||
marginTop?: string; | ||
marginBottom?: string; | ||
} | ||
|
||
export interface CalloutProps { | ||
marginTop?: string; | ||
marginBottom?: string; | ||
paddingTop?: string; | ||
paddingRight?: string; | ||
paddingBottom?: string; | ||
paddingLeft?: string; | ||
children?: React.ReactNode; | ||
variant?: CalloutVariants; | ||
} |
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
e4a3d00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deployment failed with the following error: