-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72e249e
commit 257ce14
Showing
20 changed files
with
1,455 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import { Box, Flex } from '..' | ||
import BannerWrapper from './BannerWrapper' | ||
import IconRightContainer from './IconRightContainer' | ||
import BoxToFlex from './BoxToFlex' | ||
|
||
const FullWidthButtonContainer = styled(Box)` | ||
${({ buttonRightBreakPoint, theme }) => ` | ||
display: block; | ||
${theme.mediaQueries[buttonRightBreakPoint]} { | ||
display: none; | ||
} | ||
`} | ||
` | ||
|
||
const PartialWidthButtonContainer = styled(Flex)` | ||
${({ buttonRightBreakPoint, isButtonFullWidthAtBreakPoint, theme }) => ` | ||
${ | ||
isButtonFullWidthAtBreakPoint && | ||
` | ||
display: none; | ||
${theme.mediaQueries[buttonRightBreakPoint]} { | ||
display: flex; | ||
} | ||
` | ||
} | ||
`} | ||
` | ||
|
||
const Banner = ({ | ||
badge, | ||
bgColor, | ||
borderHugLeft, | ||
borderHugTop, | ||
borderRadius, | ||
boxShadowSize, | ||
buttonRight, | ||
buttonRightBreakPoint, | ||
flexPadding, | ||
heading, | ||
hoverBoxShadowSize, | ||
iconLeft, | ||
iconRight, | ||
imageLeft, | ||
isButtonFullWidthAtBreakPoint, | ||
justifyContent, | ||
outline, | ||
px, | ||
py, | ||
text, | ||
}) => { | ||
const hasLeftContent = !!imageLeft || !!iconLeft | ||
return ( | ||
<BannerWrapper | ||
data-testid='bannerWrapper' | ||
bgColor={bgColor} | ||
borderHugLeft={borderHugLeft} | ||
borderHugTop={borderHugTop} | ||
borderRadius={borderRadius} | ||
boxShadowSize={boxShadowSize} | ||
hoverBoxShadowSize={hoverBoxShadowSize} | ||
outline={outline} | ||
px={px} | ||
py={py} | ||
> | ||
<Flex justifyContent='center' alignItems='center' p={flexPadding}> | ||
{!!imageLeft && imageLeft} | ||
{!!iconLeft && iconLeft} | ||
<BoxToFlex | ||
alignItems='center' | ||
buttonRightBreakPoint={buttonRightBreakPoint} | ||
data-testid='bannerContents' | ||
isButtonFullWidthAtBreakPoint={isButtonFullWidthAtBreakPoint} | ||
justifyContent={justifyContent} | ||
width={1} | ||
> | ||
<Box mx={[1, null, 0]} pl={hasLeftContent ? [1, null, 3] : undefined}> | ||
{!!badge && badge} | ||
{!!heading && heading} | ||
{!!text && text} | ||
</Box> | ||
{buttonRight && ( | ||
<PartialWidthButtonContainer | ||
data-testid='buttonBox' | ||
buttonRightBreakPoint={buttonRightBreakPoint} | ||
isButtonFullWidthAtBreakPoint={isButtonFullWidthAtBreakPoint} | ||
justifyContent={justifyContent === 'center' ? 'center' : 'flex-start'} | ||
ml={justifyContent === 'space-between' ? 'auto' : undefined} | ||
pl={hasLeftContent ? [2, null, 3] : undefined} | ||
pr={1} | ||
> | ||
{buttonRight} | ||
</PartialWidthButtonContainer> | ||
)} | ||
</BoxToFlex> | ||
</Flex> | ||
{buttonRight && isButtonFullWidthAtBreakPoint && ( | ||
<FullWidthButtonContainer | ||
data-testid='buttonBoxFullWidth' | ||
buttonRightBreakPoint={buttonRightBreakPoint} | ||
px={imageLeft ? 0 : 1} | ||
py={1} | ||
width={1} | ||
> | ||
{buttonRight} | ||
</FullWidthButtonContainer> | ||
)} | ||
{iconRight && <IconRightContainer>{iconRight}</IconRightContainer>} | ||
</BannerWrapper> | ||
) | ||
} | ||
|
||
Banner.defaultProps = { | ||
borderRadius: 'xl', | ||
flexPadding: [1, null, 2], | ||
isButtonFullWidthAtBreakPoint: false, | ||
justifyContent: 'space-between', | ||
px: 2, | ||
py: 2, | ||
} | ||
|
||
export default Banner |
34 changes: 34 additions & 0 deletions
34
packages/core/src/PclnBanners/BannerWrapper/BannerWrapper.tsx
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,34 @@ | ||
import { Card, getPaletteColor } from '../..' | ||
import styled from 'styled-components' | ||
|
||
const BannerWrapper = styled(Card)` | ||
position: relative; | ||
${(props) => ` | ||
background-color: ${getPaletteColor(props.bgColor)(props)}; | ||
${props.outline ? `border-color: ${getPaletteColor(props.outline)(props)}` : 'border-width: 0px'}; | ||
${ | ||
props.borderHugLeft && | ||
`border-left-width: 4px; border-left-color: ${getPaletteColor(props.borderHugLeft)(props)};` | ||
} | ||
${ | ||
props.borderHugTop && | ||
`border-top-width: 4px; border-top-color: ${getPaletteColor(props.borderHugTop)(props)};` | ||
}; | ||
${ | ||
props.hoverBoxShadowSize && | ||
`transition: box-shadow ${props.theme.timingFunctions.easeInOut} ${props.theme.duration.normal}; | ||
&:hover { box-shadow: ${props.theme.shadows.xl}; }` | ||
} | ||
`}; | ||
` | ||
|
||
BannerWrapper.defaultProps = { | ||
bgColor: 'background.lightest', | ||
outline: '', | ||
borderHugTop: '', | ||
borderHugLeft: '', | ||
} | ||
|
||
export default BannerWrapper |
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,3 @@ | ||
import BannerWrapper from './BannerWrapper' | ||
|
||
export default BannerWrapper |
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,20 @@ | ||
import { Flex } from '../..' | ||
import styled from 'styled-components' | ||
|
||
const BoxToFlex = styled(Flex)` | ||
${({ buttonRightBreakPoint, isButtonFullWidthAtBreakPoint, theme }) => | ||
buttonRightBreakPoint | ||
? ` | ||
display: block; | ||
${isButtonFullWidthAtBreakPoint ? '& button { display: none; }' : ''} | ||
> :last-child { margin-top: 8px; } | ||
${theme.mediaQueries[buttonRightBreakPoint]} { | ||
display: flex; | ||
${isButtonFullWidthAtBreakPoint ? '& button { display: block; }' : ''} | ||
> :last-child { margin-top: 0; } | ||
} | ||
` | ||
: ''} | ||
` | ||
|
||
export default BoxToFlex |
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,3 @@ | ||
import BoxToFlex from './BoxToFlex' | ||
|
||
export default BoxToFlex |
11 changes: 11 additions & 0 deletions
11
packages/core/src/PclnBanners/IconRightContainer/IconRightContainer.tsx
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,11 @@ | ||
import { Absolute } from '../..' | ||
import styled from 'styled-components' | ||
|
||
const IconRightContainer = styled(Absolute)` | ||
${({ theme }) => ` | ||
right: ${theme.space[2]}; | ||
top: ${theme.space[2]}; | ||
`} | ||
` | ||
|
||
export default IconRightContainer |
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,3 @@ | ||
import IconRightContainer from './IconRightContainer' | ||
|
||
export default IconRightContainer |
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,71 @@ | ||
import React from 'react' | ||
import { Flex } from '../..' | ||
import BannerWrapper from '../BannerWrapper' | ||
|
||
const InputBanner = ({ | ||
text, | ||
heading, | ||
imageLeft, | ||
iconLeft, | ||
outline, | ||
bgColor, | ||
buttonRight, | ||
inputs, | ||
borderHugTop, | ||
borderHugLeft, | ||
boxShadowSize, | ||
}) => ( | ||
<BannerWrapper | ||
py={imageLeft ? 0 : 3} | ||
outline={outline} | ||
bgColor={bgColor} | ||
borderHugTop={borderHugTop} | ||
borderHugLeft={borderHugLeft} | ||
boxShadowSize={boxShadowSize} | ||
borderRadius='xl' | ||
> | ||
<Flex | ||
flexDirection={['column', null, null, 'row']} | ||
data-testid='inputBannerContents' | ||
width={1} | ||
justifyContent='flex-start' | ||
alignItems='center' | ||
pr={[2, null, null, 0]} | ||
> | ||
<Flex flexDirection='row' width='100%' px={2}> | ||
<Flex> | ||
{!!imageLeft && imageLeft} | ||
{!!iconLeft && iconLeft} | ||
</Flex> | ||
<Flex flexDirection='column'> | ||
{!!heading && heading} | ||
{!!text && text} | ||
</Flex> | ||
</Flex> | ||
<Flex | ||
justifyContent={['start', null, null, 'end']} | ||
alignItems='center' | ||
flexDirection={['column', null, null, 'row']} | ||
width='100%' | ||
pl={[2, null, null, 0]} | ||
pr={[0, null, null, 2]} | ||
> | ||
<Flex width={['100%', null, null, 'unset']} pt={[2, null, null, 0]}> | ||
{inputs} | ||
</Flex> | ||
{buttonRight && ( | ||
<Flex | ||
pr={[0, null, null, 3]} | ||
pl={[0, null, null, 1]} | ||
pt={[3, null, null, 0]} | ||
width={['100%', null, null, 'unset']} | ||
> | ||
{buttonRight} | ||
</Flex> | ||
)} | ||
</Flex> | ||
</Flex> | ||
</BannerWrapper> | ||
) | ||
|
||
export default InputBanner |
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,3 @@ | ||
import InputBanner from './InputBanner' | ||
|
||
export default InputBanner |
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,4 @@ | ||
import Banner from './Banner' | ||
import InputBanner from './InputBanner' | ||
|
||
export { InputBanner, Banner as default } |
Oops, something went wrong.