From 6aecf080b84c7b8a9a8103ec595efffe91a33bb7 Mon Sep 17 00:00:00 2001 From: Alison Joseph Date: Thu, 2 May 2019 16:00:11 -0500 Subject: [PATCH] feat: add ResourceTile component --- packages/example/src/data/nav-items.yaml | 2 + .../pages/component-examples/ResourceTile.mdx | 97 ++++++++++++++ .../component-examples/images/github-icon.png | Bin 0 -> 6813 bytes packages/gatsby-theme-carbon/index.js | 1 + .../components/ResourceTile/ResourceTile.js | 126 ++++++++++++++++++ .../src/components/ResourceTile/index.js | 3 + .../ResourceTile/resource-tile.scss | 94 +++++++++++++ .../gatsby-theme-carbon/src/styles/_page.scss | 9 ++ .../gatsby-theme-carbon/src/styles/index.scss | 1 + 9 files changed, 333 insertions(+) create mode 100644 packages/example/src/pages/component-examples/ResourceTile.mdx create mode 100644 packages/example/src/pages/component-examples/images/github-icon.png create mode 100755 packages/gatsby-theme-carbon/src/components/ResourceTile/ResourceTile.js create mode 100644 packages/gatsby-theme-carbon/src/components/ResourceTile/index.js create mode 100644 packages/gatsby-theme-carbon/src/components/ResourceTile/resource-tile.scss diff --git a/packages/example/src/data/nav-items.yaml b/packages/example/src/data/nav-items.yaml index 95cc996ce..57ac8745a 100644 --- a/packages/example/src/data/nav-items.yaml +++ b/packages/example/src/data/nav-items.yaml @@ -6,6 +6,8 @@ path: /component-examples/DoDontExample - title: Caption path: /component-examples/Caption + - title: Tile + path: /component-examples/Tile # - title: ImageComponent # path: /component-examples/ImageComponent - title: Contributing diff --git a/packages/example/src/pages/component-examples/ResourceTile.mdx b/packages/example/src/pages/component-examples/ResourceTile.mdx new file mode 100644 index 000000000..97a7454a1 --- /dev/null +++ b/packages/example/src/pages/component-examples/ResourceTile.mdx @@ -0,0 +1,97 @@ +--- +title: ResourceTile +--- + +import { Row, Column, ResourceTile } from 'gatsby-theme-carbon'; + +## ResourceTile + + + + + +![](/images/github-icon.png) + + + + + + +![](/images/github-icon.png) + + + + + +### Dark + + + + + +![](/images/github-icon.png) + + + + + + +![](/images/github-icon.png) + + + + + +### Disabled + + + + + + + + + + + + + + + + + diff --git a/packages/example/src/pages/component-examples/images/github-icon.png b/packages/example/src/pages/component-examples/images/github-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6316d77ab081d5878cd290c6a8284ca9009155aa GIT binary patch literal 6813 zcmbVR2UwHKwgo|?sep791JWUo1OkLABtYmb^r9h!P9UM90)q73q$!{@=}nO;(m{Gt zID&MsfFeZ!#TPst-?{hQ``-OtzWi-w&Dv}4*|R7AmncJh&C~SU^b`~nr?rp>WAe3+ ze00&$kk7MO?yKYrod?pAL_xuD?)adj$jafQprD~}LRolO=;_L12yPN+EWsWp;pgT- zMpIBIs`z=JF)lbSfIZH^$z6%>WAjr!fD=}U&m5`;(({1h9G#E>M4U;0J_-}yf`MWA zRFnaVe)41jH=Gw5;OFM*PLlUi;`_-fPrg5HmgEEcgm}3q@u?mg1X$=90^kH94gi&q z0b;1P0xScPhJwWb5D-{a5(Je5$pArMd61ku1Pu7~;UilkV)63E2#sI1$WKaq zj$U3K@{*FizP=K^QW6BBgCrORgGquQk`M@xi~y4S-M!F$KzGvRzZeiW5{BsH;pIed z2OKk^?FrsqN_=Fcf4bo2@tfA2^ear{fJyqHJtV;rpktSQ0rdlYj3mw# z=Z16lB9XD+-&hYvf)|10NccC@zq|jz06DaJdcSS_OD%40zfF+5)P2Zq{0hjwM3Yed z9ym#39Espf#NgC@$TBYjnb?2Sdo;e}Izn z28;GW|DRwiMjlTfx}nKlJGr49aFQPG4t#*$v6P1sTnR+7VX``@zqf0_;f6#4-pQ5R zK{D1<18AwkWxy~Q86ZRg{8O%;p1hVj$qVg{!D%6s_{b5GaB{-R%V0s$5C{kdM8hC3 zptKBB4u}RxV}Y_VcpM&&$AV?$(0`3b5HQ}yd2l@b&n1B+V8|T*El&m{i?hc`$pK}g zad;pMDh&dn@%ZDDl)W@s3L_(jhyBH7Ky)InO0?_WS&vm=$&6@OdyJek7zBhup*Wy4 z7L5nWK{0Yb9Nr!RfuON6QfR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--- a/packages/gatsby-theme-carbon/index.js +++ b/packages/gatsby-theme-carbon/index.js @@ -4,4 +4,5 @@ export { default as Video } from './src/components/Video'; export { default as DoDontExample } from './src/components/DoDontExample'; export { Row, Column } from './src/components/Grid'; export { default as Caption } from './src/components/Caption'; +export { default as ResourceTile } from './src/components/ResourceTile'; //export { default as ImageComponent } from './src/components/ImageComponent'; // in progress diff --git a/packages/gatsby-theme-carbon/src/components/ResourceTile/ResourceTile.js b/packages/gatsby-theme-carbon/src/components/ResourceTile/ResourceTile.js new file mode 100755 index 000000000..87ed23c3a --- /dev/null +++ b/packages/gatsby-theme-carbon/src/components/ResourceTile/ResourceTile.js @@ -0,0 +1,126 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import classnames from 'classnames'; +import { ClickableTile } from 'carbon-components-react'; +import Launch20 from '@carbon/icons-react/es/launch/20'; +import Download20 from '@carbon/icons-react/es/download/20'; +import ArrowRight20 from '@carbon/icons-react/es/arrow--right/20'; +import Error20 from '@carbon/icons-react/es/error/20'; +import { settings } from 'carbon-components'; + +const { prefix } = settings; + +export default class ResourceTile extends React.Component { + static propTypes = { + children: PropTypes.node, + + /** + * Set url for tile + */ + href: PropTypes.string, + + /** + * Smaller heading + */ + subTitle: PropTypes.string, + + /** + * Large heading + */ + title: PropTypes.string, + + /** + * Action icon, default is launch, options are Launch, ArrowRight, Download, Error + */ + actionIcon: PropTypes.string, + + /** + * Set tile aspect ratio, default is 2:1 + */ + aspectRatio: PropTypes.bool, + + /** + * Use for dark tile + */ + dark: PropTypes.bool, + + /** + * Use for disabled tile + */ + disabled: PropTypes.bool, + + /** + * Specify a custom class + */ + className: PropTypes.string, + }; + + static defaultProps = { + dark: false, + disabled: false, + aspectRatio: '2:1', + actionIcon: 'launch', + }; + + render() { + const { + children, + href, + subTitle, + title, + dark, + disabled, + aspectRatio, + actionIcon, + className, + } = this.props; + + const classNames = classnames([`${prefix}--resource-tile`], { + [className]: className, + [`${prefix}--resource-tile--disabled`]: disabled, + [`${prefix}--resource-tile--dark`]: dark, + }); + + const aspectRatioClassNames = classnames([`${prefix}--aspect-ratio`], { + [`${prefix}--aspect-ratio--2x1`]: aspectRatio === '2:1', + [`${prefix}--aspect-ratio--1x1`]: aspectRatio === '1:1', + // Add other aspect ratio classes here + }); + + return ( +
+
+
+ +
+ {subTitle} +
+

{title}

+
+ {children} +
+
+ {actionIcon === 'launch' && !disabled ? ( + + ) : null} + {actionIcon === 'arrowRight' && !disabled ? ( + + ) : null} + {actionIcon === 'download' && !disabled ? ( + + ) : null} + {actionIcon === 'disabled' || disabled === true ? ( + + ) : null} +
+
+
+
+
+ ); + } +} diff --git a/packages/gatsby-theme-carbon/src/components/ResourceTile/index.js b/packages/gatsby-theme-carbon/src/components/ResourceTile/index.js new file mode 100644 index 000000000..29ebf04ca --- /dev/null +++ b/packages/gatsby-theme-carbon/src/components/ResourceTile/index.js @@ -0,0 +1,3 @@ +import ResourceTile from './ResourceTile'; + +export default ResourceTile; diff --git a/packages/gatsby-theme-carbon/src/components/ResourceTile/resource-tile.scss b/packages/gatsby-theme-carbon/src/components/ResourceTile/resource-tile.scss new file mode 100644 index 000000000..623154ebe --- /dev/null +++ b/packages/gatsby-theme-carbon/src/components/ResourceTile/resource-tile.scss @@ -0,0 +1,94 @@ +.#{$prefix}--resource-tile .#{$prefix}--tile { + background: $ui-background; + height: 100%; + padding: $spacing-05; + position: relative; + transition: background $duration--fast-01; + text-decoration: none; +} + +.#{$prefix}--resource-tile .#{$prefix}--tile:hover { + background: $hover-ui; +} + +.#{$prefix}--resource-tile__title { + @include carbon--type-style('productive-heading-03'); + text-decoration: none; + color: $text-01; +} + +.#{$prefix}--resource-tile__subtitle { + @include carbon--type-style('body-short-02'); + text-decoration: none; + color: $text-01; +} + +.#{$prefix}--resource-tile__icon--img { + position: absolute; + bottom: 1rem; + left: 1rem; + width: 32px; + height: 32px; +} + +.#{$prefix}--resource-tile__icon--action { + position: absolute; + bottom: 1rem; + right: 1rem; + width: 20px; + height: 20px; +} + +// Dark +.#{$prefix}--resource-tile--dark .#{$prefix}--tile { + background: $carbon--gray-90; //$ui-background for gray 90 theme +} + +.#{$prefix}--resource-tile--dark .#{$prefix}--tile:hover { + background: $carbon--gray-80; //$hover-ui for gray 90 theme +} + +.#{$prefix}--resource-tile--dark .#{$prefix}--resource-tile__title, +.#{$prefix}--resource-tile--dark .#{$prefix}--resource-tile__subtitle { + color: $text-04; +} + +.#{$prefix}--resource-tile--dark .#{$prefix}--resource-tile__icon--action svg { + fill: $carbon--white-0; +} + +// Disabled +.#{$prefix}--resource-tile--disabled .#{$prefix}--tile:hover { + background: $ui-background; + cursor: not-allowed; +} + +.#{$prefix}--resource-tile--disabled .#{$prefix}--resource-tile__title, +.#{$prefix}--resource-tile--disabled .#{$prefix}--resource-tile__subtitle { + color: $disabled-03; +} + +.#{$prefix}--resource-tile--disabled + .#{$prefix}--resource-tile__icon--action + svg { + fill: $disabled-02; +} + +// Disabled dark +.#{$prefix}--resource-tile--disabled.#{$prefix}--resource-tile--dark + .#{$prefix}--tile:hover { + background: $carbon--gray-90; //$ui-background for gray 90 theme +} + +.#{$prefix}--resource-tile--disabled.#{$prefix}--resource-tile--dark + .#{$prefix}--resource-tile__title, +.#{$prefix}--resource-tile--disabled.#{$prefix}--resource-tile--dark + .#{$prefix}--resource-tile__subtitle { + color: $carbon--gray-50; //$disabled-023for gray 90 +} + +.#{$prefix}--resource-tile--disabled.#{$prefix}--resource-tile--dark + .#{$prefix}--resource-tile__icon--action + svg { + fill: $carbon--gray-70; //$disabled-02 for gray 90 +} diff --git a/packages/gatsby-theme-carbon/src/styles/_page.scss b/packages/gatsby-theme-carbon/src/styles/_page.scss index 2fbfb9cc9..69829e050 100644 --- a/packages/gatsby-theme-carbon/src/styles/_page.scss +++ b/packages/gatsby-theme-carbon/src/styles/_page.scss @@ -128,6 +128,15 @@ em { margin-bottom: $spacing-06; } +.gatsby-resp-image-background-image { + background: transparent !important; // Need important to override inline style added by gatsby-remark-images +} + +.gatsby-resp-image-image { + box-shadow: none !important; // Need important to override inline style added by gatsby-remark-images + border: none !important; +} + // iframe .gatsby-resp-iframe-wrapper { position: relative; diff --git a/packages/gatsby-theme-carbon/src/styles/index.scss b/packages/gatsby-theme-carbon/src/styles/index.scss index 51d0a509b..7eb10ee67 100644 --- a/packages/gatsby-theme-carbon/src/styles/index.scss +++ b/packages/gatsby-theme-carbon/src/styles/index.scss @@ -56,4 +56,5 @@ $font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif; @import '../components/DoDontExample/do-dont-example.scss'; @import '../components/AnchorLinks/anchor-links.scss'; @import '../components/Caption/caption.scss'; +@import '../components/ResourceTile/resource-tile.scss'; //@import '../components/ImageComponent/image-component.scss'; //WIP