This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Terra-Image] Adds support for Decorative Image (#3712)
* Added support for Decorative Image * removes additional wrappers around image component * linters updated * typo corrections * doc updates --------- Co-authored-by: SM051274 <sm051274@cerner.net>
- Loading branch information
1 parent
fbdaa53
commit 960a56e
Showing
26 changed files
with
756 additions
and
23 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
Binary file added
BIN
+11.1 MB
...c/terra-dev-site/common/images/creative-commons/Matterhorn,_March_2019_(01).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.6 KB
...dev-site/common/images/creative-commons/Matterhorn,_March_2019_(01)_150x150.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.57 MB
...v-site/common/images/creative-commons/Matterhorn,_March_2019_(01)_1920x1280.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+165 KB
...dev-site/common/images/creative-commons/Matterhorn,_March_2019_(01)_480x320.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+510 KB
...dev-site/common/images/creative-commons/Matterhorn,_March_2019_(01)_960x640.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
39 changes: 39 additions & 0 deletions
39
packages/terra-core-docs/src/terra-dev-site/common/layout-helpers/Whitespace.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import classNamesBind from 'classnames/bind'; | ||
import styles from './Whitespace.module.scss'; | ||
|
||
const cx = classNamesBind.bind(styles); | ||
|
||
const propTypes = { | ||
/** | ||
* Sets the height of a newline spacer, equivalent to number of lines based on lineheight, not fontsize. | ||
* One of `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, default is `1`. | ||
*/ | ||
newline: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8]), | ||
}; | ||
|
||
const defaultProps = { | ||
newline: 1, | ||
}; | ||
|
||
const Whitespace = ({ | ||
newline, | ||
...customProps | ||
}) => { | ||
const WhitespaceClassNames = classNames( | ||
cx( | ||
'whitespace', | ||
`newline-${newline}`, | ||
), | ||
customProps.className, | ||
); | ||
|
||
return <div {...customProps} className={WhitespaceClassNames} aria-hidden="true" />; | ||
}; | ||
|
||
Whitespace.propTypes = propTypes; | ||
Whitespace.defaultProps = defaultProps; | ||
|
||
export default Whitespace; |
48 changes: 48 additions & 0 deletions
48
packages/terra-core-docs/src/terra-dev-site/common/layout-helpers/Whitespace.module.scss
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,48 @@ | ||
/* | ||
* SASS calculation | ||
* based on lineheight of 20px (1.42857) for fontsize of 14px (1rem) | ||
*/ | ||
@mixin terra-newline-height ($number-of-lines) { | ||
height: 1.4285714286em * $number-of-lines; | ||
} | ||
|
||
:local { | ||
.whitespace { | ||
display: block; | ||
margin: 0; | ||
min-height: 0; | ||
padding: 0; | ||
} | ||
|
||
.newline-1 { | ||
@include terra-newline-height(1); | ||
} | ||
|
||
.newline-2 { | ||
@include terra-newline-height(2); | ||
} | ||
|
||
.newline-3 { | ||
@include terra-newline-height(3); | ||
} | ||
|
||
.newline-4 { | ||
@include terra-newline-height(4); | ||
} | ||
|
||
.newline-5 { | ||
@include terra-newline-height(5); | ||
} | ||
|
||
.newline-6 { | ||
@include terra-newline-height(6); | ||
} | ||
|
||
.newline-7 { | ||
@include terra-newline-height(7); | ||
} | ||
|
||
.newline-8 { | ||
@include terra-newline-height(8); | ||
} | ||
} |
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
317 changes: 317 additions & 0 deletions
317
packages/terra-core-docs/src/terra-dev-site/doc/image/AccessibilityGuide.2.doc.mdx
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
Binary file added
BIN
+5.07 KB
packages/terra-core-docs/src/terra-dev-site/doc/image/assets/crocus.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+93 Bytes
packages/terra-core-docs/src/terra-dev-site/doc/image/assets/decorative-bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
packages/terra-core-docs/src/terra-dev-site/doc/image/example/A11yExampleDecorativeImage.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import classNamesBind from 'classnames/bind'; | ||
import Card from 'terra-card'; | ||
import Image from 'terra-image'; | ||
import matterhornBackgroundImage from '../../../../common/images/creative-commons/Matterhorn,_March_2019_(01)_960x640.jpg'; | ||
import styles from './common/A11yExamples.module.scss'; | ||
|
||
const cx = classNamesBind.bind(styles); | ||
|
||
const A11yExampleDecorativeImage = () => ( | ||
<div className={cx('decorative-example')}> | ||
<Image src={matterhornBackgroundImage} fit="cover" className={cx('background')} /> | ||
<div className={cx('foreground')}> | ||
<Card className={cx('card')}> | ||
<p className={cx('decorative-text-container')}> | ||
<strong className={cx('title')}>Matterhorn</strong> | ||
Standing at 4,478 meters (14,692ft), Matterhorn is the fifth highest peak in the Alps located on the border between Switzerland and Italy, in the Monte Rosa area of the western Pennine Alps, and overlooks the Swiss town of Zermatt. | ||
<cite className={cx('cite')}> | ||
<small> | ||
{'Photo Credit: '} | ||
<a href="https://commons.wikimedia.org/wiki/File:Matterhorn,_March_2019_(01).jpg">Liridon</a> | ||
{', '} | ||
<a href="https://creativecommons.org/licenses/by-sa/4.0">CC BY-SA 4.0</a> | ||
, via Wikimedia Commons | ||
</small> | ||
</cite> | ||
</p> | ||
</Card> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default A11yExampleDecorativeImage; |
21 changes: 21 additions & 0 deletions
21
packages/terra-core-docs/src/terra-dev-site/doc/image/example/A11yExampleInformative.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import classNamesBind from 'classnames/bind'; | ||
import Card from 'terra-card'; | ||
import Image from 'terra-image'; | ||
import matterhornImage from '../../../common/images/creative-commons/Matterhorn,_March_2019_(01)_150x150.jpg'; | ||
import styles from './common/A11yExamples.module.scss'; | ||
|
||
const cx = classNamesBind.bind(styles); | ||
|
||
const matterhornAlternativeText = 'North-east face of the Matterhorn mountain peak and surrounding landscape covered in snow against a blue sky, located in the Swiss Apps near Zermatt, Switzerland'; | ||
|
||
const A11yGuideInformativeImage = () => ( | ||
<Card className={cx('card')}> | ||
<p className={cx('informative-example')}> | ||
<Image src={matterhornImage} alt={matterhornAlternativeText} className={cx('image')} /> | ||
<strong className={cx('title')}>Matterhorn</strong> | ||
</p> | ||
</Card> | ||
); | ||
|
||
export default A11yGuideInformativeImage; |
29 changes: 29 additions & 0 deletions
29
...es/terra-core-docs/src/terra-dev-site/doc/image/example/A11yExampleInformativeConcise.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import classNamesBind from 'classnames/bind'; | ||
import Card from 'terra-card'; | ||
import Image from 'terra-image'; | ||
import matterhornImage from '../../../common/images/creative-commons/Matterhorn,_March_2019_(01)_150x150.jpg'; | ||
import styles from './common/A11yExamples.module.scss'; | ||
|
||
const cx = classNamesBind.bind(styles); | ||
|
||
const matterhornAlternativeText = 'Matterhorn mountain peak'; | ||
|
||
export default () => ( | ||
<Card className={cx('card')}> | ||
<p className={cx('informative-example')}> | ||
<Image src={matterhornImage} alt={matterhornAlternativeText} className={cx('image')} /> | ||
<strong className={cx('title')}>Matterhorn</strong> | ||
Standing at 4,478 meters (14,692ft), Matterhorn is the fifth highest peak in the Alps located on the border between Switzerland and Italy, in the Monte Rosa area of the western Pennine Alps, and overlooks the Swiss town of Zermatt. | ||
<cite className={cx('cite')}> | ||
<small> | ||
{'Photo Credit: '} | ||
<a href="https://commons.wikimedia.org/wiki/File:Matterhorn,_March_2019_(01).jpg">Liridon</a> | ||
{', '} | ||
<a href="https://creativecommons.org/licenses/by-sa/4.0">CC BY-SA 4.0</a> | ||
, via Wikimedia Commons | ||
</small> | ||
</cite> | ||
</p> | ||
</Card> | ||
); |
18 changes: 18 additions & 0 deletions
18
packages/terra-core-docs/src/terra-dev-site/doc/image/example/DecorativeImage.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import Image from 'terra-image'; | ||
import decorativeBar from '../assets/decorative-bar.png'; | ||
import crocus from '../assets/crocus.jpg'; | ||
|
||
const DecorativeImageBar = () => ( | ||
<div> | ||
<h2>Image used as part of page design.</h2> | ||
<p>This image is used as a border in the page design and has a purely decorative purpose.</p> | ||
<Image src={decorativeBar} /> | ||
<h2>Image as part of a text link.</h2> | ||
<p>This illustration of a crocus bulb is used to make the link easier to identify and to increase the clickable area but doesn’t add to the information already provided in the adjacent link text (of the same anchor). In this case, alt value for the image would be `null` / `empty`.</p> | ||
<Image src={crocus} /> | ||
<a href="https://engineering.cerner.com/terra-ui/components/cerner-terra-core-docs/image/about#examples"><span>Crocus bulbs</span></a> | ||
</div> | ||
); | ||
|
||
export default DecorativeImageBar; |
15 changes: 15 additions & 0 deletions
15
packages/terra-core-docs/src/terra-dev-site/doc/image/example/InformativeImage.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import Image from 'terra-image'; | ||
import matterhornImage from '../../../common/images/creative-commons/Matterhorn,_March_2019_(01)_150x150.jpg'; | ||
|
||
const matterhornAlternativeText = 'North-east face of the Matterhorn mountain peak and surrounding landscape covered in snow against a blue sky, located in the Swiss Apps near Zermatt, Switzerland'; | ||
|
||
const InformativeImage = () => ( | ||
<div> | ||
<h2>Information provided using Image.</h2> | ||
<Image src={matterhornImage} alt={matterhornAlternativeText} /> | ||
<p><strong>Matterhorn</strong></p> | ||
</div> | ||
); | ||
|
||
export default InformativeImage; |
72 changes: 72 additions & 0 deletions
72
...ages/terra-core-docs/src/terra-dev-site/doc/image/example/common/A11yExamples.module.scss
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,72 @@ | ||
:local { | ||
.card { | ||
width: 100%; | ||
} | ||
|
||
.informative-example { | ||
font-size: 0.85rem; | ||
margin-left: auto; | ||
margin-right: auto; | ||
max-width: 40rem; | ||
padding: 0.25rem 1rem 0; | ||
text-align: center; | ||
width: 100%; | ||
} | ||
|
||
.image { | ||
margin: 0 auto; | ||
} | ||
|
||
.title { | ||
display: block; | ||
font-size: 1.1em; | ||
margin-bottom: 0.25em; | ||
margin-top: 0.5em; | ||
} | ||
|
||
.cite { | ||
display: block; | ||
margin-top: 0.25em; | ||
} | ||
|
||
.decorative-example { | ||
min-height: 240px; | ||
position: relative; | ||
width: 100%; | ||
|
||
.background { | ||
height: 240px; | ||
width: 100%; | ||
} | ||
|
||
.foreground { | ||
padding: 20px; | ||
position: absolute; | ||
top: 0; | ||
width: 100%; | ||
} | ||
|
||
.card { | ||
opacity: 0.85; | ||
} | ||
} | ||
|
||
.decorative-text-container { | ||
font-size: 0.85rem; | ||
padding-left: 1rem; | ||
padding-right: 1rem; | ||
text-align: center; | ||
} | ||
|
||
@media screen and (min-width: 544px) { | ||
.informative-example { | ||
font-size: 1rem; | ||
} | ||
|
||
.decorative-text-container { | ||
font-size: 1rem; | ||
padding-left: 3rem; | ||
padding-right: 3rem; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
|
||
## Unreleased | ||
|
||
* Added | ||
* Added support for decorative images. | ||
|
||
## 3.36.0 - (December 7, 2022) | ||
|
||
* Changed | ||
|
Oops, something went wrong.