Skip to content

Commit

Permalink
chore(nav-drawer): use gap property for spacing (#364)
Browse files Browse the repository at this point in the history
* chore(nav-drawer): use gap property for spacing

Co-authored-by: Simeon Simeonoff <[email protected]>
  • Loading branch information
SisIvanova and simeonoff authored May 17, 2022
1 parent 17944be commit b573922
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
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

0 comments on commit b573922

Please sign in to comment.