diff --git a/src/components.d.ts b/src/components.d.ts index e1d75795..93458b13 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -1776,6 +1776,7 @@ export namespace Components { * Data test is the prop to specifically test the component action object. */ "dataTest"?: string; + "disable"?: boolean; /** * Icon. Used to add icon in list item. */ @@ -1784,6 +1785,7 @@ export namespace Components { * A prop for make the nav open. */ "isOpen"?: boolean; + "loading"?: boolean; /** * SecondaryText. Used to insert a secondaryText in the display item. */ @@ -5469,6 +5471,7 @@ declare namespace LocalJSX { * Data test is the prop to specifically test the component action object. */ "dataTest"?: string; + "disable"?: boolean; /** * Icon. Used to add icon in list item. */ @@ -5477,6 +5480,7 @@ declare namespace LocalJSX { * A prop for make the nav open. */ "isOpen"?: boolean; + "loading"?: boolean; /** * When de open or close of component change, the event are dispache. */ diff --git a/src/components/loading-spinner/readme.md b/src/components/loading-spinner/readme.md index a383fc6d..636b31e0 100644 --- a/src/components/loading-spinner/readme.md +++ b/src/components/loading-spinner/readme.md @@ -21,12 +21,14 @@ - [bds-autocomplete](../autocomplete) - [bds-button](../button) + - [bds-nav-tree](../nav-tree) ### Graph ```mermaid graph TD; bds-autocomplete --> bds-loading-spinner bds-button --> bds-loading-spinner + bds-nav-tree --> bds-loading-spinner style bds-loading-spinner fill:#f9f,stroke:#333,stroke-width:4px ``` diff --git a/src/components/nav-tree/nav-tree.scss b/src/components/nav-tree/nav-tree.scss index 52fb26e7..fba04c4c 100644 --- a/src/components/nav-tree/nav-tree.scss +++ b/src/components/nav-tree/nav-tree.scss @@ -23,6 +23,15 @@ border: 1px solid transparent; overflow: hidden; + &--loading { + cursor: wait; + } + + &--disable { + opacity: 0.5; + cursor:not-allowed; + } + &:before { content: ''; position: absolute; @@ -42,6 +51,13 @@ opacity: 0.08; } } + + &--disable { + &:before, &:hover { + border-color: transparent; + background-color: transparent; + } + } & .icon-item { position: relative; @@ -60,10 +76,16 @@ & .title-item { color: $color-content-default; + &--loading { + color: $color-content-disable; + } } & .subtitle-item { color: $color-content-default; + &--loading { + color: $color-content-disable; + } } } @@ -78,6 +100,10 @@ transition: all ease 0.3s; transform: rotate(0deg); + &--disable { + color: $color-content-disable; + } + &_active { transform: rotate(180deg); } @@ -112,7 +138,14 @@ background-color: $color-hover; opacity: .8; } + + &--disable { + &:before { + background-color: transparent; + } + } } + } .nav_tree { diff --git a/src/components/nav-tree/nav-tree.tsx b/src/components/nav-tree/nav-tree.tsx index 8bdd2e5c..3591c54c 100644 --- a/src/components/nav-tree/nav-tree.tsx +++ b/src/components/nav-tree/nav-tree.tsx @@ -36,6 +36,15 @@ export class NavTree { * Data test is the prop to specifically test the component action object. */ @Prop() dataTest?: string = null; +/** + * Loading state. Indicates if the component is in a loading state. + */ + @Prop() loading?: boolean = false; + + /** + * Disable state. Indicates if the component is disabled. + */ + @Prop() disable?: boolean = false; /** * When de open or close of component change, the event are dispache. */ @@ -43,7 +52,9 @@ export class NavTree { @Method() async toggle() { - this.isOpen = !this.isOpen; + if (!this.disable) { + this.isOpen = !this.isOpen; + } } @Watch('isOpen') @@ -56,11 +67,13 @@ export class NavTree { } private handler = (): void => { - this.isOpen = !this.isOpen; + if (!this.loading && !this.disable) { + this.isOpen = !this.isOpen; + } }; private handleKeyDown(event) { - if (event.key == 'Enter') { + if (event.key == 'Enter' && !this.disable) { this.isOpen = !this.isOpen; } } @@ -70,54 +83,75 @@ export class NavTree {
- {this.icon && ( - - )} -
-
+