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

chore(nav-drawer): use gap property for spacing #364

Merged
merged 4 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 10 additions & 2 deletions src/components/nav-drawer/nav-drawer-item.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { html, LitElement } from 'lit';
import { property, queryAssignedElements, state } from 'lit/decorators.js';
import {
property,
queryAssignedElements,
queryAssignedNodes,
state,
} from 'lit/decorators.js';
import { themes } from '../../theming/theming-decorator.js';
import { partNameMap } from '../common/util.js';
import { styles as indigo } from './styles/indigo/nav-drawer-item.indigo.css.js';
Expand Down Expand Up @@ -36,6 +41,9 @@ export default class IgcNavDrawerItemComponent extends LitElement {
@queryAssignedElements({ slot: 'content' })
private _text!: Array<HTMLElement>;

@queryAssignedNodes({ slot: 'icon', flatten: true })
protected navdrawerIcon!: Array<Node>;

public override connectedCallback() {
super.connectedCallback();
this.shadowRoot?.addEventListener('slotchange', (_) => {
Expand All @@ -53,7 +61,7 @@ export default class IgcNavDrawerItemComponent extends LitElement {
protected override render() {
return html`
<div part="${partNameMap(this.resolvePartNames('base'))}">
<span part="icon">
<span part="icon" .hidden="${this.navdrawerIcon.length == 0}">
<slot name="icon"></slot>
</span>
<span part="content">
Expand Down
9 changes: 7 additions & 2 deletions src/components/nav-drawer/nav-drawer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ describe('Navigation Drawer', () => {
});

it('render nav drawer item slots successfully', async () => {
expect(el.children[0]).shadowDom.equal(`
expect(el.children[0]).shadowDom.equal(
`
<div part="base">
<span part="icon">
<slot name="icon"></slot>
Expand All @@ -62,7 +63,11 @@ describe('Navigation Drawer', () => {
<slot name="content"></slot>
</span>
</div>
`);
`,
{
ignoreAttributes: ['hidden'],
}
);
});

it('render nav drawer slots successfully', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[part~='base'] {
@include border-radius(rem(24px));

gap: rem(24px);
color: color(gray, 300, .8);
padding: rem(4px);
margin: rem(15px) rem(8px) !important;
Expand All @@ -13,21 +14,11 @@
background: transparent;
color: color(gray, 100);
}

::slotted(igc-icon) {
margin-inline-end: rem(24px);
}
}

[part='content'] {
padding-inline-start: rem(8px);
}

[part='base mini'] {
::slotted(igc-icon) {
margin-inline-end: 0;
}
}
}

:host([active]) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/nav-drawer/styles/nav-drawer-item.base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $item-margin: rem(8px);

[part~='base'] {
display: flex;
gap: rem(32px);
align-items: center;
flex-flow: row nowrap;
position: relative;
Expand All @@ -28,7 +29,6 @@ $item-margin: rem(8px);
::slotted(igc-icon) {
display: flex;
font: inherit;
margin-inline-end: rem(32px);
}

&:hover {
Expand All @@ -53,7 +53,6 @@ $item-margin: rem(8px);

::slotted(igc-icon) {
width: 100%;
margin-inline-end: 0;
}
}

Expand Down