-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'range-slider-docs' of https://github.com/laurenmrice/ca…
…rbon-website into range-slider-docs
- Loading branch information
Showing
129 changed files
with
2,855 additions
and
722 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
BACKEND_URI=https://carbondesignsystem.vercel.app/api/survey | ||
BACKEND_URI=https://carbondesignsystem.vercel.app/api/survey |
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
176 changes: 176 additions & 0 deletions
176
src/gatsby-theme-carbon/components/ArticleCard/ArticleCard.js
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,176 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cx from 'classnames'; | ||
import { Link } from 'gatsby'; | ||
import { | ||
Launch, | ||
Download, | ||
ArrowRight, | ||
Error, | ||
Email, | ||
} from '@carbon/react/icons'; | ||
|
||
export default class ArticleCard extends React.Component { | ||
render() { | ||
const { | ||
children, | ||
href, | ||
title, | ||
subTitle, | ||
author, | ||
date, | ||
readTime, | ||
color, | ||
disabled, | ||
actionIcon, | ||
className, | ||
...rest | ||
} = this.props; | ||
|
||
// const prefix = 'cds'; | ||
|
||
let isLink; | ||
if (href !== undefined) { | ||
isLink = href.charAt(0) === '/'; | ||
} | ||
|
||
const ArticleCardClassNames = cx(className, `cds--article-card`, { | ||
[`cds--article-card--disabled`]: disabled, | ||
[`cds--article-card--dark`]: color === 'dark', | ||
}); | ||
|
||
const aspectRatioClassNames = cx( | ||
[`cds--aspect-ratio`], | ||
[`cds--aspect-ratio--2x1`] | ||
); | ||
|
||
const cardContentClassNames = cx( | ||
[`cds--tile`], | ||
[`cds--tile--clickable`], | ||
[`cds--article-card_content`] | ||
); | ||
|
||
const cardContent = ( | ||
<> | ||
<div className="cds--article-card__img">{children}</div> | ||
<div className={aspectRatioClassNames}> | ||
<div className="cds--aspect-ratio--object cds--article-card__tile"> | ||
{subTitle ? ( | ||
<h5 className="cds--article-card__subtitle">{subTitle}</h5> | ||
) : null} | ||
{title ? ( | ||
<h4 className="cds--article-card__title">{title}</h4> | ||
) : null} | ||
<div className="cds--article-card__info"> | ||
{author ? ( | ||
<p className="cds--article-card__author">{author}</p> | ||
) : null} | ||
{date ? <p className="cds--article-card__date">{date}</p> : null} | ||
{readTime ? ( | ||
<p className="cds--article-card__read-time">{readTime}</p> | ||
) : null} | ||
</div> | ||
<div className="cds--article-card__icon--action"> | ||
{actionIcon === 'launch' && !disabled ? ( | ||
<Launch size={20} aria-label="Open" /> | ||
) : null} | ||
{actionIcon === 'arrowRight' && !disabled ? ( | ||
<ArrowRight size={20} aria-label="Open" /> | ||
) : null} | ||
{actionIcon === 'download' && !disabled ? ( | ||
<Download size={20} aria-label="Download" /> | ||
) : null} | ||
{actionIcon === 'email' && !disabled ? ( | ||
<Email size={20} aria-label="Email" /> | ||
) : null} | ||
{actionIcon === 'disabled' || disabled === true ? ( | ||
<Error size={20} aria-label="disabled" /> | ||
) : null} | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
|
||
let cardContainer; | ||
if (disabled === true) { | ||
cardContainer = ( | ||
<div className={cardContentClassNames}>{cardContent}</div> | ||
); | ||
} else if (isLink === true) { | ||
cardContainer = ( | ||
<Link to={href} className={cardContentClassNames} {...rest}> | ||
{cardContent} | ||
</Link> | ||
); | ||
} else { | ||
cardContainer = ( | ||
<a href={href} className={cardContentClassNames} {...rest}> | ||
{cardContent} | ||
</a> | ||
); | ||
} | ||
|
||
return <div className={ArticleCardClassNames}>{cardContainer}</div>; | ||
} | ||
} | ||
|
||
ArticleCard.propTypes = { | ||
/** | ||
* Action icon, default is blank, options are Launch, ArrowRight, Download | ||
*/ | ||
actionIcon: PropTypes.string, | ||
|
||
/** | ||
* Author | ||
*/ | ||
author: PropTypes.string, | ||
|
||
children: PropTypes.node, | ||
|
||
/** | ||
* Specify a custom class | ||
*/ | ||
className: PropTypes.string, | ||
|
||
/** | ||
* set to "dark" for dark background card | ||
*/ | ||
color: PropTypes.string, | ||
|
||
/** | ||
* date | ||
*/ | ||
date: PropTypes.string, | ||
|
||
/** | ||
* Use for disabled card | ||
*/ | ||
disabled: PropTypes.bool, | ||
|
||
/** | ||
* Set url for card | ||
*/ | ||
href: PropTypes.string, | ||
|
||
/** | ||
* Reat time of article | ||
*/ | ||
readTime: PropTypes.string, | ||
|
||
/** | ||
* sub title | ||
*/ | ||
subTitle: PropTypes.string, | ||
|
||
/** | ||
* Title | ||
*/ | ||
title: PropTypes.string, | ||
}; | ||
|
||
ArticleCard.defaultProps = { | ||
color: 'light', | ||
disabled: false, | ||
actionIcon: '', | ||
}; |
142 changes: 142 additions & 0 deletions
142
src/gatsby-theme-carbon/components/ArticleCard/article-card.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,142 @@ | ||
// $carbon--white-0 | ||
@use '@carbon/react/scss/colors' as *; | ||
// $spacing-0X | ||
@use '@carbon/react/scss/spacing' as *; | ||
// carbon--type-style | ||
@use '@carbon/react/scss/type' as *; | ||
// color tokens | ||
@use '@carbon/react/scss/compat/theme' as *; | ||
// $standard-easing $transition-x | ||
@use '@carbon/react/scss/motion' as *; | ||
// carbon--breakpoint | ||
@use '@carbon/react/scss/breakpoint' as *; | ||
|
||
.cds--article-card .cds--tile { | ||
height: 100%; | ||
padding: 0; | ||
position: relative; | ||
transition: background $duration-fast-01; | ||
text-decoration: none; | ||
border: 1px solid $border-tile-01; | ||
|
||
@include breakpoint('lg') { | ||
margin-bottom: var(--space); | ||
} | ||
} | ||
|
||
.cds--article-card__tile { | ||
border-top: 1px solid $border-tile-01; | ||
padding: $spacing-05 25% $spacing-05 $spacing-05; | ||
} | ||
|
||
// Dark | ||
.cds--article-card--dark .cds--article-card__tile { | ||
background: $gray-90; //$ui-background for gray 90 theme | ||
} | ||
|
||
.cds--article-card:hover .cds--article-card__tile { | ||
background: $hover-ui; | ||
} | ||
|
||
.cds--article-card__title { | ||
@include type-style('body-short-02'); | ||
text-decoration: none; | ||
color: $text-01; | ||
} | ||
|
||
.cds--article-card__subtitle { | ||
@include type-style('heading-01'); | ||
font-weight: 400; | ||
text-decoration: none; | ||
color: $text-01; | ||
} | ||
|
||
.cds--article-card__info { | ||
position: absolute; | ||
bottom: 1rem; | ||
left: 1rem; | ||
padding: 0; | ||
color: $text-02; | ||
} | ||
|
||
.cds--article-card__info p { | ||
@include type-style('label-01'); | ||
} | ||
|
||
// At the moment, we force 16:9 for medium posts, this | ||
// is how we would force 16:9 for all article cards | ||
// .cds--article-card__img { | ||
// aspect-ratio: 16 / 9; | ||
// } | ||
|
||
.cds--article-card__img .gatsby-resp-image-wrapper { | ||
margin-bottom: 0; | ||
} | ||
|
||
.cds--article-card__icon--action { | ||
position: absolute; | ||
bottom: 1rem; | ||
right: 1rem; | ||
width: 20px; | ||
height: 20px; | ||
} | ||
|
||
.cds--article-card__icon--action svg { | ||
fill: $icon-01; | ||
} | ||
|
||
.cds--article-card--dark:hover .cds--article-card__tile { | ||
background: $gray-80; //$hover-ui for gray 90 theme | ||
} | ||
|
||
.cds--article-card--dark .cds--article-card__title, | ||
.cds--article-card--dark .cds--article-card__subtitle { | ||
color: $text-04; | ||
} | ||
|
||
.cds--article-card--dark .cds--article-card__info { | ||
color: $gray-30; //$text-02 for gray 90 theme | ||
} | ||
|
||
.cds--article-card--dark .cds--article-card__icon--action svg { | ||
fill: $gray-10; //$icon-01 for grsay 90 theme | ||
} | ||
|
||
// Disabled | ||
.cds--article-card--disabled { | ||
cursor: not-allowed; | ||
} | ||
|
||
.cds--article-card--disabled .cds--article-card__tile:hover { | ||
background: $ui-01; | ||
cursor: not-allowed; | ||
} | ||
|
||
.cds--article-card--disabled .cds--article-card__title, | ||
.cds--article-card--disabled .cds--article-card__subtitle, | ||
.cds--article-card--disabled .cds--article-card__info { | ||
color: $disabled-03; | ||
} | ||
|
||
.cds--article-card--disabled .cds--article-card__icon--action svg { | ||
fill: $disabled-02; | ||
} | ||
|
||
// Disabled dark | ||
.cds--article-card--disabled.cds--article-card--dark | ||
.cds--article-card__tile:hover { | ||
background: $gray-90; //$ui-background for gray 90 theme | ||
} | ||
|
||
.cds--article-card--disabled.cds--article-card--dark .cds--article-card__title, | ||
.cds--article-card--disabled.cds--article-card--dark | ||
.cds--article-card__subtitle, | ||
.cds--article-card--disabled.cds--article-card--dark .cds--article-card__info { | ||
color: $gray-50; //$disabled-03 for gray 90 | ||
} | ||
|
||
.cds--article-card--disabled.cds--article-card--dark | ||
.cds--article-card__icon--action | ||
svg { | ||
fill: $gray-70; //$disabled-02 for gray 90 | ||
} |
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 ArticleCard from './ArticleCard'; | ||
|
||
export default ArticleCard; |
Oops, something went wrong.