Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(card-section): introducing web component versions #4471

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/node_modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
@license

Copyright IBM Corp. 2020

This source code is licensed under the Apache-2.0 license found in the
LICENSE file in the root directory of this source tree.
-->

<html>
<head>
<title>@carbon/ibmdotcom-web-components example</title>
<meta charset="UTF-8" />
<script type="module" src="src/index.js"></script>
<style type="text/css">
/* Avoids FOUC - Will be overriden by `index.scss` */
body {
visibility: hidden;
}
</style>
</head>
<body>
<div class="bx--grid">
<div class="bx--row">
<div class="bx--col-sm-4">
<dds-card-section-images heading="Aliquam condimentum interdum">
<dds-card-group>
<dds-card-group-item href="https://example.com">
<dds-image slot="image" alt="Image alt text" default-src="https://dummyimage.com/1056x792/ee5396/161616&amp;text=4:3">
</dds-image>
<div slot="eyebrow">Topic</div>
<div slot="heading">Natural Language Processing.</div>
<dds-card-footer slot="footer">
${ArrowRight20({ slot: 'icon' })}
</dds-card-footer>
</dds-card-group-item>
</dds-card-group>
</dds-card-section-images>
</div>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "ibmdotcom-web-components-card-section-images-example",
"version": "0.1.0",
"private": true,
"description": "Sample project for getting started with the Web Components from Carbon for IBM.com.",
"license": "Apache-2",
"scripts": {
"start": "snowpack dev",
"build": "snowpack build"
},
"dependencies": {
"@carbon/ibmdotcom-web-components": "canary",
"carbon-components": "~10.17.0",
"lit-element": "~2.4.0",
"lit-html": "~1.3.0"
},
"devDependencies": {
"snowpack": "2.10.1",
"snowpack-plugin-sass": "^1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"template": "node"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"snowpack-plugin-sass"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @license
*
* Copyright IBM Corp. 2020
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import '@carbon/ibmdotcom-web-components/es/components/card-section-images/card-section-images.js';
import '@carbon/ibmdotcom-web-components/es/components/card-group/card-group.js';
import '@carbon/ibmdotcom-web-components/es/components/card-group/card-group-item.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// @license
//
// Copyright IBM Corp. 2020
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

// `enable-css-custom-properties` and `grid-columns-16` feature flags are requirements for Carbon for IBM.com styles
$feature-flags: (
enable-css-custom-properties: true,
grid-columns-16: true,
);

@import 'carbon-components/scss/globals/grid/grid';

body {
visibility: inherit;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/node_modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!--
@license

Copyright IBM Corp. 2020

This source code is licensed under the Apache-2.0 license found in the
LICENSE file in the root directory of this source tree.
-->

<html>
<head>
<title>@carbon/ibmdotcom-web-components example</title>
<meta charset="UTF-8" />
<script type="module" src="src/index.js"></script>
<style type="text/css">
/* Avoids FOUC - Will be overriden by `index.scss` */
body {
visibility: hidden;
}
</style>
</head>
<body>
<div class="bx--grid">
<div class="bx--row">
<div class="bx--col-sm-4">
<dds-card-section-simple heading="Aliquam condimentum interdum">
<dds-card-group>
<dds-card-group-item href="https://example.com">
<div slot="heading">Nunc convallis lobortis</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean et ultricies est. Mauris iaculis eget dolor nec hendrerit.
Phasellus at elit sollicitudin, sodales nulla quis, consequat libero.
</p>
<dds-card-footer slot="footer">
${ArrowRight20({ slot: 'icon' })}
</dds-card-footer>
</dds-card-group-item>
</dds-card-group>
</dds-card-section-simple>
</div>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "ibmdotcom-web-components-card-section-simple-example",
"version": "0.1.0",
"private": true,
"description": "Sample project for getting started with the Web Components from Carbon for IBM.com.",
"license": "Apache-2",
"scripts": {
"start": "snowpack dev",
"build": "snowpack build"
},
"dependencies": {
"@carbon/ibmdotcom-web-components": "canary",
"carbon-components": "~10.17.0",
"lit-element": "~2.4.0",
"lit-html": "~1.3.0"
},
"devDependencies": {
"snowpack": "2.10.1",
"snowpack-plugin-sass": "^1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"template": "node"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"snowpack-plugin-sass"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @license
*
* Copyright IBM Corp. 2020
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import '@carbon/ibmdotcom-web-components/es/components/card-section-simple/card-section-simple.js';
import '@carbon/ibmdotcom-web-components/es/components/card-group/card-group.js';
import '@carbon/ibmdotcom-web-components/es/components/card-group/card-group-item.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// @license
//
// Copyright IBM Corp. 2020
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

// `enable-css-custom-properties` and `grid-columns-16` feature flags are requirements for Carbon for IBM.com styles
$feature-flags: (
enable-css-custom-properties: true,
grid-columns-16: true,
);

@import 'carbon-components/scss/globals/grid/grid';

body {
visibility: inherit;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Props, Description } from '@storybook/addon-docs/blocks';
import contributing from '../../../../../../docs/contributing-license.md';
import markdownContents from '../../../../docs/markdown-contents.md';

# `<dds-card-section-images>`

> The Card Section - Images pattern is a collection of cards with images presented in a section with a left-column header.
> 💡 Check our
> [CodeSandbox](https://githubbox.com/carbon-design-system/carbon-for-ibm-dotcom/tree/master/packages/web-components/examples/codesandbox/components/card-section-images)
> example implementation.
[![Edit @carbon/ibmdotcom-web-components](https://codesandbox.io/static/img/play-codesandbox.svg)](https://githubbox.com/carbon-design-system/carbon-for-ibm-dotcom/tree/master/packages/web-components/examples/codesandbox/components/card-section-images)

## Getting started

Here's a quick example to get you started.

##### JS

```javascript

import '@carbon/ibmdotcom-web-components/es/components/card-section-images/card-section-images.js';
import '@carbon/ibmdotcom-web-components/es/components/card-group/card-group.js';
import '@carbon/ibmdotcom-web-components/es/components/card-group/card-group-item.js';

```

### HTML

```html
<dds-card-section-images heading="Aliquam condimentum interdum">
<dds-card-group>
<dds-card-group-item href="https://example.com">
<dds-image slot="image" alt="Image alt text" default-src="https://dummyimage.com/1056x792/ee5396/161616&amp;text=4:3">
</dds-image>
<div slot="eyebrow">Topic</div>
<div slot="heading">Natural Language Processing.</div>
<dds-card-footer slot="footer">
${ArrowRight20({ slot: 'icon' })}
</dds-card-footer>
</dds-card-group-item>
</dds-card-group>
</dds-card-section-images>
```

## Props

<Props of="dds-card-section-images" />
<Description markdown={markdownContents} />

## Stable selectors

See [our README](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/tree/master/packages/web-components#stable-selectors-for-analytics-and-integratione2e-testing-in-web-components) to see how Web Components selector and `data-autoid` should be used.

| Web Components selector | Compatibility selector | Description |
| ----------------------------- | ----------------------------------------- | ----------- |
| `<dds-card-section-images>` | `data-autoid="dds--card-section-images"` | Component |

<Description markdown={contributing} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @license
*
* Copyright IBM Corp. 2020
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import { html } from 'lit-element';
import ArrowRight20 from 'carbon-web-components/es/icons/arrow--right/20';
import ifNonNull from 'carbon-web-components/es/globals/directives/if-non-null.js';
import readme from './README.stories.mdx';
import textNullable from '../../../../.storybook/knob-text-nullable';
import '../../content-section/content-section';
import '../../card-group/card-group';
import '../../card-group/card-group-item';
import '../card-section-images';

const cardGroupItemWithImages = html`
<dds-card-group-item href="https://example.com">
<dds-image slot="image" alt="Image alt text" default-src="https://dummyimage.com/1056x792/ee5396/161616&amp;text=4:3">
</dds-image>
<div slot="eyebrow">Topic</div>
<div slot="heading">Natural Language Processing.</div>
<dds-card-footer slot="footer">
${ArrowRight20({ slot: 'icon' })}
</dds-card-footer>
</dds-card-group-item>
`;

export const Default = ({ parameters }) => {
const { heading, cards } = parameters?.props?.CardSectionImages ?? {};
return html`
<dds-card-section-images heading=${ifNonNull(heading)}>
<dds-card-group>${cards}</dds-card-group>
</dds-card-section-images>
`;
};

export default {
title: 'Components/Card Section Images',
decorators: [
story => html`
<div class="bx--grid bx--content-group-story dds-ce-demo-devenv--grid--stretch">
<div class="bx--row dds-ce-demo-devenv--grid-row">
<div class="bx--col-sm-4">
${story()}
</div>
</div>
</div>
`,
],
parameters: {
...readme.parameters,
hasGrid: true,
hasVerticalSpacingInComponent: true,
knobs: {
CardSectionImages: ({ groupId }) => ({
heading: textNullable('Heading (required)', 'Aliquam condimentum interdum', groupId),
cards: Array.from({
length: 5,
}).map(() => cardGroupItemWithImages),
}),
},
},
};
Loading