-
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(callout): web-component created #3983
Changes from 6 commits
98817be
702c664
96cca89
639ba70
8be611e
c48f575
04dc335
699c394
802ab03
23fe112
fe8601e
beffca6
d33e7f6
58af217
e1a1e2e
c76c3ef
a91c9c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @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, render } from 'lit-html'; | ||
import '../callout.scss'; | ||
|
||
const template = () => html` | ||
<dds-callout> | ||
<h1>Hey testing!</h1> | ||
</dds-callout> | ||
`; | ||
|
||
describe('dds-callout', function() { | ||
it('renders properly', async function() { | ||
await render(template(), document.body); | ||
await Promise.resolve(); | ||
expect(document.body.querySelector('dds-callout')).toMatchSnapshot({ mode: 'shadow' }); | ||
}); | ||
afterEach(async function() { | ||
await render(undefined!, document.body); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// 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-styles/scss/internal/callout/callout'; |
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. | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
import { customElement, html, LitElement } from 'lit-element'; | ||||||||||||||||||||||||||
import settings from 'carbon-components/es/globals/js/settings'; | ||||||||||||||||||||||||||
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings'; | ||||||||||||||||||||||||||
import styles from './callout.scss'; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const { prefix } = settings; | ||||||||||||||||||||||||||
const { stablePrefix: ddsPrefix } = ddsSettings; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Link list. | ||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||
* @element dds-link-list | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
@customElement(`${ddsPrefix}-callout`) | ||||||||||||||||||||||||||
class DDSCallout extends LitElement { | ||||||||||||||||||||||||||
static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
static get stableSelector() { | ||||||||||||||||||||||||||
return `${ddsPrefix}--callout`; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// eslint-disable-next-line class-methods-use-this | ||||||||||||||||||||||||||
protected render() { | ||||||||||||||||||||||||||
return html` | ||||||||||||||||||||||||||
<div class="${prefix}--callout__container"> | ||||||||||||||||||||||||||
<div class="${prefix}--callout__column"> | ||||||||||||||||||||||||||
<div class="${prefix}--callout__content"> | ||||||||||||||||||||||||||
<slot /> | ||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||
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. To avoid duplicate elements (host and
Suggested change
Please make sure the host element has the style of 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. I've updated it, thanks for the review! 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. @asudoh We still need the container, in order to maintain the structure seen in the styles package scss |
||||||||||||||||||||||||||
`; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export default DDSCallout; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @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 { render } from 'lit-html'; | ||
import DDSLinkList from '../link-list'; | ||
import { Default, Horizontal, Vertical, VerticalWithCards, EndOfSection } from '../__stories__/link-list.stories'; | ||
|
||
describe('dds-link-list', function() { | ||
it('Renders Default', async function() { | ||
render(Default(), document.body); | ||
await Promise.resolve(); | ||
expect(document.body.querySelector('dds-link-list')).toMatchSnapshot({ mode: 'shadow' }); | ||
}); | ||
|
||
it('Renders Horizontal', async function() { | ||
render(Horizontal(), document.body); | ||
await Promise.resolve(); | ||
expect(document.body.querySelector('dds-link-list')).toMatchSnapshot({ mode: 'shadow' }); | ||
}); | ||
|
||
it('Renders Vertical', async function() { | ||
render(Vertical(), document.body); | ||
await Promise.resolve(); | ||
expect(document.body.querySelector('dds-link-list')).toMatchSnapshot({ mode: 'shadow' }); | ||
}); | ||
|
||
it('Renders Vertical with cards', async function() { | ||
render(VerticalWithCards(), document.body); | ||
await Promise.resolve(); | ||
expect(document.body.querySelector('dds-link-list')).toMatchSnapshot({ mode: 'shadow' }); | ||
}); | ||
|
||
it('Renders End of section', async function() { | ||
render(EndOfSection(), document.body); | ||
await Promise.resolve(); | ||
expect(document.body.querySelector('dds-link-list')).toMatchSnapshot({ mode: 'shadow' }); | ||
}); | ||
|
||
it('Tests the get methods', function() { | ||
expect((DDSLinkList as typeof DDSLinkList).stableSelector).toBe('dds--link-list'); | ||
expect((DDSLinkList as typeof DDSLinkList).splitLayoutClass).toBe('bx--link-list__split'); | ||
expect((DDSLinkList as typeof DDSLinkList).linkListItemSelector).toBe('dds-link-list-item'); | ||
}); | ||
|
||
afterEach(async function() { | ||
await render(undefined!, document.body); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# `dds-callout` | ||
|
||
#### `renders properly` | ||
|
||
``` | ||
<div class="bx--callout__container"> | ||
<div class="bx--callout__column"> | ||
<div class="bx--callout__content"> | ||
<slot> | ||
</slot> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# `dds-link-list` | ||
|
||
#### `Renders Default` | ||
|
||
``` | ||
<h4 class="bx--link-list__heading"> | ||
<slot name="heading"> | ||
</slot> | ||
</h4> | ||
<ul | ||
class="bx--link-list__list bx--link-list__list--card" | ||
name="list" | ||
> | ||
<slot> | ||
</slot> | ||
</ul> | ||
``` | ||
|
||
#### `Renders Horizontal` | ||
|
||
``` | ||
<h4 class="bx--link-list__heading"> | ||
<slot name="heading"> | ||
</slot> | ||
</h4> | ||
<ul | ||
class="bx--link-list__list bx--link-list__list--horizontal" | ||
name="list" | ||
> | ||
<slot> | ||
</slot> | ||
</ul> | ||
``` | ||
|
||
#### `Renders Vertical` | ||
|
||
``` | ||
<h4 class="bx--link-list__heading"> | ||
<slot name="heading"> | ||
</slot> | ||
</h4> | ||
<ul | ||
class="bx--link-list__list bx--link-list__list--vertical" | ||
name="list" | ||
> | ||
<slot> | ||
</slot> | ||
</ul> | ||
``` | ||
|
||
#### `Renders Vertical with cards` | ||
|
||
``` | ||
<h4 class="bx--link-list__heading"> | ||
<slot name="heading"> | ||
</slot> | ||
</h4> | ||
<ul | ||
class="bx--link-list__list bx--link-list__list--vertical" | ||
name="list" | ||
> | ||
<slot> | ||
</slot> | ||
</ul> | ||
``` | ||
|
||
#### `Renders End of section` | ||
|
||
``` | ||
<h4 class="bx--link-list__heading"> | ||
<slot name="heading"> | ||
</slot> | ||
</h4> | ||
<ul | ||
class="bx--link-list__list dds-ce--link-list__list--end" | ||
name="list" | ||
> | ||
<slot> | ||
</slot> | ||
</ul> | ||
``` | ||
|
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.
To align to the rest of the codebase:
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.
I've updated it, thanks for the review!