-
Notifications
You must be signed in to change notification settings - Fork 33
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
Showing
9 changed files
with
259 additions
and
183 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
client/src/lib/components/BackgroundBlock/BackgroundBlock.library.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,35 @@ | ||
import React from 'react'; | ||
import {Spacer48, Spacer96} from '../Spacers/Spacer'; | ||
import BackgroundBlock from './BackgroundBlock'; | ||
import {COLORS} from '../../../../../shared/src/constants/colors'; | ||
import styled from 'styled-components/native'; | ||
import {Heading24} from '../Typography/Heading/Heading'; | ||
|
||
const Wrapper = styled.View({ | ||
flex: 1, | ||
backgroundColor: COLORS.BLACK, | ||
}); | ||
|
||
export const AllTypes = () => ( | ||
<Wrapper> | ||
<Spacer96 /> | ||
|
||
<BackgroundBlock backgroundColor={COLORS.PURE_WHITE}> | ||
<Heading24>Test test</Heading24> | ||
</BackgroundBlock> | ||
<Spacer48 /> | ||
|
||
<BackgroundBlock backgroundColor={COLORS.PURE_WHITE}> | ||
<Spacer96 /> | ||
<Heading24>Test test</Heading24> | ||
<Spacer96 /> | ||
</BackgroundBlock> | ||
<Spacer48 /> | ||
|
||
<BackgroundBlock backgroundColor={COLORS.ERROR}> | ||
<Spacer96 /> | ||
<Heading24>Test test</Heading24> | ||
<Spacer96 /> | ||
</BackgroundBlock> | ||
</Wrapper> | ||
); |
69 changes: 69 additions & 0 deletions
69
client/src/lib/components/BackgroundBlock/BackgroundBlock.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,69 @@ | ||
import hexToRgba from 'hex-to-rgba'; | ||
import React from 'react'; | ||
import LinearGradient, { | ||
LinearGradientProps, | ||
} from 'react-native-linear-gradient'; | ||
import styled from 'styled-components/native'; | ||
|
||
const FADE_HEIGHT = 36; | ||
|
||
type FadeProps = { | ||
color: string; | ||
}; | ||
const Fade = styled(LinearGradient).attrs({ | ||
pointerEvents: 'none', | ||
})<FadeProps>({ | ||
position: 'absolute', | ||
height: FADE_HEIGHT, | ||
left: 0, | ||
right: 0, | ||
backgroundColor: 'none', | ||
}); | ||
|
||
const TopFade = styled(Fade).attrs<FadeProps, LinearGradientProps>( | ||
({color}) => ({ | ||
colors: [hexToRgba(color, 0), hexToRgba(color, 1)], | ||
}), | ||
)({ | ||
top: 0, | ||
}); | ||
|
||
const BottomFade = styled(Fade).attrs<FadeProps, LinearGradientProps>( | ||
({color}) => ({ | ||
colors: [hexToRgba(color, 1), hexToRgba(color, 0)], | ||
}), | ||
)({ | ||
bottom: 0, | ||
}); | ||
|
||
const Background = styled.View<{backgroundColor: string}>( | ||
({backgroundColor}) => ({ | ||
position: 'absolute', | ||
top: FADE_HEIGHT, | ||
bottom: FADE_HEIGHT, | ||
left: 0, | ||
right: 0, | ||
backgroundColor, | ||
}), | ||
); | ||
|
||
const Wrapper = styled.View({ | ||
minHeight: FADE_HEIGHT * 2, | ||
justifyContent: 'center', | ||
}); | ||
|
||
type Props = { | ||
backgroundColor: string; | ||
children: React.ReactNode; | ||
}; | ||
|
||
const BackgroundBlock: React.FC<Props> = ({backgroundColor, children}) => ( | ||
<Wrapper> | ||
<Background backgroundColor={backgroundColor} /> | ||
<TopFade color={backgroundColor} /> | ||
<BottomFade color={backgroundColor} /> | ||
{children} | ||
</Wrapper> | ||
); | ||
|
||
export default BackgroundBlock; |
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
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
Oops, something went wrong.