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

Feature/six sidebar expose container part #263

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Upcoming

- Expose `container` part in `six-sidebar` for external styling

### Added

### Changed
Expand Down
18 changes: 12 additions & 6 deletions docs/components/six-sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,11 @@ The following has many filler section elements to clearly show that the selected

## Properties

| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ----------------------------------------------------------------------------------------- | ------------------- | --------- |
| `open` | `open` | Indicates whether the sidebar is open. You can use this in lieu of the show/hide methods. | `boolean` | `false` |
| `position` | `position` | Sidebar position | `"left" \| "right"` | `'left'` |
| `toggled` | `toggled` | Define whether sidebar is toggled meaning only one menu can be open at the same time | `boolean` | `false` |
| `width` | `width` | Sidebar width | `string` | `'16rem'` |
| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ----------------------------------------------------------------------------------------- | ------------------- | -------- |
| `open` | `open` | Indicates whether the sidebar is open. You can use this in lieu of the show/hide methods. | `boolean` | `false` |
| `position` | `position` | Sidebar position | `"left" \| "right"` | `'left'` |
| `toggled` | `toggled` | Define whether sidebar is toggled meaning only one menu can be open at the same time | `boolean` | `false` |


## Events
Expand Down Expand Up @@ -360,6 +359,13 @@ Type: `Promise<void>`
| | Used to define the nested side bar [group] items. |


## Shadow Parts

| Part | Description |
| ------------- | ----------- |
| `"container"` | |


----------------------------------------------

Copyright Β© 2021-present SIX-Group
Original file line number Diff line number Diff line change
Expand Up @@ -1197,15 +1197,15 @@ export declare interface SixSelect extends Components.SixSelect {


@ProxyCmp({
inputs: ['open', 'position', 'toggled', 'width'],
inputs: ['open', 'position', 'toggled'],
methods: ['toggle', 'show', 'hide', 'selectItemByIndex', 'selectItemByName']
})
@Component({
selector: 'six-sidebar',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['open', 'position', 'toggled', 'width'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would mean we have a breaking change, I guess we could include this in the release which also targets node 18 and above but not before.

cc: @ibirrer

inputs: ['open', 'position', 'toggled'],
})
export class SixSidebar {
protected el: HTMLElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ export const SixSelect = /*@__PURE__*/ defineContainer<JSX.SixSelect, JSX.SixSel
export const SixSidebar = /*@__PURE__*/ defineContainer<JSX.SixSidebar>('six-sidebar', undefined, [
'position',
'open',
'width',
'toggled',
'six-sidebar-show',
'six-sidebar-after-show',
Expand Down
8 changes: 0 additions & 8 deletions libraries/ui-library/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1479,10 +1479,6 @@ export namespace Components {
* Define whether sidebar is toggled meaning only one menu can be open at the same time
*/
"toggled": boolean;
/**
* Sidebar width
*/
"width": string;
}
/**
* @since 1.0
Expand Down Expand Up @@ -4631,10 +4627,6 @@ declare namespace LocalJSX {
* Define whether sidebar is toggled meaning only one menu can be open at the same time
*/
"toggled"?: boolean;
/**
* Sidebar width
*/
"width"?: string;
}
/**
* @since 1.0
Expand Down
18 changes: 12 additions & 6 deletions libraries/ui-library/src/components/six-sidebar/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ If you want the user to execute an intermediary task and force a context-switch

## Properties

| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ----------------------------------------------------------------------------------------- | ------------------- | --------- |
| `open` | `open` | Indicates whether the sidebar is open. You can use this in lieu of the show/hide methods. | `boolean` | `false` |
| `position` | `position` | Sidebar position | `"left" \| "right"` | `'left'` |
| `toggled` | `toggled` | Define whether sidebar is toggled meaning only one menu can be open at the same time | `boolean` | `false` |
| `width` | `width` | Sidebar width | `string` | `'16rem'` |
| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ----------------------------------------------------------------------------------------- | ------------------- | -------- |
| `open` | `open` | Indicates whether the sidebar is open. You can use this in lieu of the show/hide methods. | `boolean` | `false` |
| `position` | `position` | Sidebar position | `"left" \| "right"` | `'left'` |
| `toggled` | `toggled` | Define whether sidebar is toggled meaning only one menu can be open at the same time | `boolean` | `false` |


## Events
Expand Down Expand Up @@ -102,6 +101,13 @@ Type: `Promise<void>`
| | Used to define the nested side bar [group] items. |


## Shadow Parts

| Part | Description |
| ------------- | ----------- |
| `"container"` | |


----------------------------------------------

Copyright Β© 2021-present SIX-Group
24 changes: 19 additions & 5 deletions libraries/ui-library/src/components/six-sidebar/six-sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
@import 'src/global/mixins/scrollbar';

:host {
--width: 16rem;

display: block;
height: 100%;
}
Expand All @@ -13,13 +15,11 @@
height: 100%;
overflow: auto;

&.sidebar--open {
border-right: 1px solid var(--six-color-web-rock-300);
}

&:not(.sidebar--visible) {
@include hidden;
}

width: var(--width);
}

&--left {
Expand All @@ -31,14 +31,28 @@
background-size: 300vw 70%;
background-position: bottom;
background-repeat: no-repeat;

margin-left: calc(1rem - var(--width));

&.sidebar--open {
margin-left: 0;
border-right: 1px solid var(--six-color-web-rock-300);
}
}

&--right {
// collapse
transition: var(--six-transition-medium) margin-right;

margin-right: calc(1rem - var(--width));

&.sidebar--open {
margin-right: 0;
border-left: 1px solid var(--six-color-web-rock-300);
}
}

// if the sidebar is embedded within six-root it cuts-off the border styling, for thus we need to guarante a margin
// if the sidebar is embedded within six-root it cuts-off the border styling, for thus we need to guarantee a margin
&--open {
&.sidebar--left {
margin-right: 2px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ export class SixSidebar {
/** Indicates whether the sidebar is open. You can use this in lieu of the show/hide methods. */
@Prop({ mutable: true, reflect: true }) open = false;

/** Sidebar width */
@Prop() width = '16rem';

/** Define whether sidebar is toggled meaning only one menu can be open at the same time*/
@Prop() toggled = false;

Expand Down Expand Up @@ -243,17 +240,14 @@ export class SixSidebar {
return (
<host class="six-sidebar">
<div
part="container"
class={{
sidebar__container: true,
'sidebar--visible': this.isVisible,
'sidebar--open': this.open,
'sidebar--left': this.position === 'left',
'sidebar--right': this.position === 'right',
}}
style={{
width: this.width,
[`margin-${this.position}`]: this.open ? '0' : `calc(1rem - ${this.width})`,
}}
ref={(el) => (this.sidebar = el)}
aria-hidden={this.open ? 'false' : 'true'}
onTransitionEnd={this.handleTransitionEnd}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('six-sidebar', () => {
<six-sidebar>
<mock:shadow-root>
<host class="six-sidebar">
<div aria-hidden="true" class="sidebar--left sidebar__container" style="width: 16rem; margin-left: calc(1rem - 16rem);">
<div aria-hidden="true" class="sidebar--left sidebar__container" part="container">
<slot></slot>
</div>
</host>
Expand Down
Loading