This repository has been archived by the owner on Aug 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3611 from bbc/add-dark-mode-image-placeholder
Implementing 'dark mode' for psammead-image-placeholder
- Loading branch information
Showing
8 changed files
with
46 additions
and
8 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
2 changes: 1 addition & 1 deletion
2
packages/components/psammead-image-placeholder/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
packages/components/psammead-image-placeholder/src/__snapshots__/index.test.jsx.snap
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
20 changes: 14 additions & 6 deletions
20
packages/components/psammead-image-placeholder/src/index.jsx
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,24 +1,32 @@ | ||
import styled from 'styled-components'; | ||
import { number } from 'prop-types'; | ||
import { C_CHALK } from '@bbc/psammead-styles/colours'; | ||
import { BBC_BLOCKS } from '@bbc/psammead-assets/svgs'; | ||
import { number, bool } from 'prop-types'; | ||
import { C_CHALK, C_SHADOW } from '@bbc/psammead-styles/colours'; | ||
import { BBC_BLOCKS, BBC_BLOCKS_DARK_MODE } from '@bbc/psammead-assets/svgs'; | ||
|
||
const bgImageDark = `url(data:image/svg+xml;base64,${BBC_BLOCKS_DARK_MODE})`; | ||
const bgImageRegular = `url(data:image/svg+xml;base64,${BBC_BLOCKS})`; | ||
|
||
const ImagePlaceholder = styled.div` | ||
position: relative; | ||
height: 0; | ||
overflow: hidden; | ||
background-color: ${C_CHALK}; | ||
background-color: ${({ darkMode }) => (darkMode ? C_SHADOW : C_CHALK)}; | ||
background-position: center center; | ||
background-repeat: no-repeat; | ||
background-size: 30%; | ||
padding-bottom: ${props => props.ratio}%; | ||
width: 100%; | ||
/* placeholder BBC blocks SVG */ | ||
background-image: url(data:image/svg+xml;base64,${BBC_BLOCKS}); | ||
background-image: ${({ darkMode }) => | ||
darkMode ? bgImageDark : bgImageRegular}; | ||
`; | ||
|
||
ImagePlaceholder.propTypes = { | ||
ratio: number.isRequired, | ||
darkMode: bool, | ||
}; | ||
|
||
ImagePlaceholder.defaultProps = { | ||
darkMode: false, | ||
}; | ||
|
||
export default ImagePlaceholder; |
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