-
Notifications
You must be signed in to change notification settings - Fork 159
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(cta-section): web component version #4338
Merged
kodiakhq
merged 21 commits into
carbon-design-system:master
from
IgnacioBecerra:cta-web-components
Nov 9, 2020
Merged
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
92818f4
feat(cta-section): introduction
IgnacioBecerra 0f883ea
feat(cta-section): default story completed
IgnacioBecerra d955fdf
feat(cta-section): web component introduced
IgnacioBecerra 7b7b2ca
Merge branch 'master' into cta-web-components
IgnacioBecerra b220282
feat(cta-section): default story completed
IgnacioBecerra 80d563b
feat(cta-section): introducing content item footer
IgnacioBecerra 6aaa740
feat(cta-section): introducing link list footer
IgnacioBecerra 74603ab
feat(cta-section): added new cta-section-copy component
IgnacioBecerra c71b413
Merge branch 'master' into cta-web-components
IgnacioBecerra ff785c1
feat(cta-section): now using tag selector for component styling
IgnacioBecerra 359e8db
Merge branch 'master' into cta-web-components
IgnacioBecerra d65e4b4
feat(cta-section): removed duplicate render from conflict
IgnacioBecerra 6d7b49e
Merge branch 'cta-web-components' of https://github.com/IgnacioBecerr…
IgnacioBecerra a287065
Merge branch 'master' into cta-web-components
jeffchew ec6fe34
feat(cta-section): fixed README formatting
IgnacioBecerra a6f0436
feat(cta-section): fixed prettier error
IgnacioBecerra 24d0222
Merge branch 'master' into cta-web-components
IgnacioBecerra d2650ee
feat(cta-section): fixed components after merging
IgnacioBecerra 763d420
feat(cta-section): fixed cta-section-copy
IgnacioBecerra a32b33b
feat(cta-section): fixed old component usage
IgnacioBecerra 75ad7e6
Merge branch 'master' into cta-web-components
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 2 additions & 0 deletions
2
packages/web-components/examples/codesandbox/components/cta-section/.gitignore
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,2 @@ | ||
/build | ||
/node_modules |
42 changes: 42 additions & 0 deletions
42
packages/web-components/examples/codesandbox/components/cta-section/index.html
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,42 @@ | ||
<!-- | ||
@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">"Lorem ipsum *dolor* sit amet" | ||
<div class="bx--col-sm-4 bx-col-lg-12 bx--offset-lg-4"> | ||
<dds-cta-section> | ||
<dds-content-block-heading>Curabitur malesuada varius mi eu posuere</dds-content-block-heading> | ||
<dds-cta-section-copy content=${ifNonNull(copy)}></dds-cta-section-copy> | ||
<dds-button-group slot='buttons'> | ||
<dds-button-group-item href="https://example.com"> | ||
Primary Button | ||
</dds-button-group-item> | ||
<dds-button-group-item href="https://example.com"> | ||
Primary button | ||
</dds-button-group-item> | ||
</dds-button-group> | ||
</dds-cta-section> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
21 changes: 21 additions & 0 deletions
21
packages/web-components/examples/codesandbox/components/cta-section/package.json
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 @@ | ||
{ | ||
"name": "ibmdotcom-web-components-cta-section-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" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/web-components/examples/codesandbox/components/cta-section/sandbox.config.json
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 @@ | ||
{ | ||
"template": "node" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/web-components/examples/codesandbox/components/cta-section/snowpack.config.json
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,5 @@ | ||
{ | ||
"plugins": [ | ||
"snowpack-plugin-sass" | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/web-components/examples/codesandbox/components/cta-section/src/index.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,13 @@ | ||
/** | ||
* @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/content-block/content-block-heading.js'; | ||
import '@carbon/ibmdotcom-web-components/es/components/cta-section/cta-section.js'; | ||
import '@carbon/ibmdotcom-web-components/es/components/button-group/button-group.js'; | ||
|
20 changes: 20 additions & 0 deletions
20
packages/web-components/examples/codesandbox/components/cta-section/src/index.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,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; | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/web-components/src/components/content-item/content-item-copy.ts
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,45 @@ | ||
/** | ||
* @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 { css, customElement } from 'lit-element'; | ||
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js'; | ||
import StableSelectorMixin from '../../globals/mixins/stable-selector'; | ||
import DDSMarkdown from '../markdown/markdown'; | ||
import './content-item-paragraph'; | ||
import styles from './content-item.scss'; | ||
|
||
const { stablePrefix: ddsPrefix } = ddsSettings; | ||
|
||
@customElement(`${ddsPrefix}-content-item-copy`) | ||
class DDSContentItemCopy extends StableSelectorMixin(DDSMarkdown) { | ||
protected get _customTags() { | ||
const tags = new Set(super._customTags); | ||
tags.add(`${ddsPrefix}-content-item-paragraph`); | ||
return tags; | ||
} | ||
|
||
protected get _renderer() { | ||
return Object.assign(super._renderer, { | ||
paragraph(text) { | ||
return `<${ddsPrefix}-content-item-paragraph>${text}</${ddsPrefix}-content-item-paragraph>`; | ||
}, | ||
}); | ||
} | ||
|
||
static get stableSelector() { | ||
return `${ddsPrefix}--content-item__copy`; | ||
} | ||
|
||
// `styles` here is a `CSSResult` generated by custom WebPack loader | ||
static get styles() { | ||
return css`${super.styles}${styles}`; | ||
} | ||
} | ||
|
||
export default DDSContentItemCopy; |
32 changes: 32 additions & 0 deletions
32
packages/web-components/src/components/content-item/content-item-paragraph.ts
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,32 @@ | ||
/** | ||
* @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, customElement, LitElement } from 'lit-element'; | ||
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js'; | ||
import styles from './content-item.scss'; | ||
|
||
const { stablePrefix: ddsPrefix } = ddsSettings; | ||
|
||
/** | ||
* The paragraph content in content item. | ||
* | ||
* @element dds-content-item-paragraph | ||
*/ | ||
@customElement(`${ddsPrefix}-content-item-paragraph`) | ||
class DDSContentItemParagraph extends LitElement { | ||
render() { | ||
return html` | ||
<slot></slot> | ||
`; | ||
} | ||
|
||
static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader | ||
} | ||
|
||
export default DDSContentItemParagraph; |
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
59 changes: 59 additions & 0 deletions
59
packages/web-components/src/components/cta-section/__stories__/README.stories.mdx
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,59 @@ | ||||||||
import { Props, Description } from '@storybook/addon-docs/blocks'; | ||||||||
import contributing from '../../../../../../docs/contributing-license.md'; | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
# `<dds-cta-section>` | ||||||||
|
||||||||
> Use the CTASection to provide additional contextual information for the section or page with specific calls to action. | ||||||||
> 💡 Check our | ||||||||
> [CodeSandbox](https://githubbox.com/carbon-design-system/carbon-for-ibm-dotcom/tree/master/packages/web-components/examples/codesandbox/components/cta-section) | ||||||||
> 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/cta-section) | ||||||||
## Getting started | ||||||||
|
||||||||
Here's a quick example to get you started. | ||||||||
|
||||||||
##### JS | ||||||||
|
||||||||
```javascript | ||||||||
|
||||||||
import '@carbon/ibmdotcom-web-components/es/components/cta-section/cta-section'; | ||||||||
import '@carbon/ibmdtocom-web-components/es/components/cta-section/cta-section-copy'; | ||||||||
import '@carbon/ibmdtocom-web-components/es/components/cta-section/cta-section-item'; | ||||||||
import '@carbon/ibmdtocom-web-components/es/components/cta-section/cta-section-heading'; | ||||||||
import '@carbon/ibmdtocom-web-components/es/components/cta-section/cta-section-item-copy'; | ||||||||
import '@carbon/ibmdotcom-web-components/es/components/content-block/content-block-heading'; | ||||||||
import '@carbon/ibmdotcom-web-components/es/components/button-group/button-group'; | ||||||||
import '@carbon/ibmdotcom-web-components/es/components/button-group/button-group-item'; | ||||||||
|
||||||||
``` | ||||||||
|
||||||||
### HTML | ||||||||
|
||||||||
```html | ||||||||
<dds-cta-section> | ||||||||
<dds-content-block-heading>Curabitur malesuada varius mi eu posuere</dds-content-block-heading> | ||||||||
<dds-cta-section-copy content="Lorem ipsum *dolor* sit amet"></dds-cta-section-copy> | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
<dds-button-group slot='buttons'> | ||||||||
<dds-button-group-item href="https://example.com"> | ||||||||
Primary Button | ||||||||
</dds-button-group-item> | ||||||||
<dds-button-group-item href="https://example.com"> | ||||||||
Primary button | ||||||||
</dds-button-group-item> | ||||||||
</dds-button-group> | ||||||||
</dds-cta-section> | ||||||||
``` | ||||||||
|
||||||||
## Props | ||||||||
|
||||||||
<Props of="dds-cta-section" /> | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
## 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-cta-section>` | `data-autoid="dds--cta-section"` | Component | | ||||||||
|
||||||||
<Description markdown={contributing} /> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.