-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add navigation-item component #1167
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e9dac0b
feat: add navigation-item component
nmerget fe1852a
Merge branch 'main' into feat-nav-item-component
nmerget 972f22b
feat: add main-navigation (#1172)
nmerget 664e122
Revert "feat: add main-navigation (#1172)"
nmerget ed691d0
fix: revert main-navigation changes
nmerget 9572995
Merge branch 'main' into feat-nav-item-component
nmerget 7dd4f50
Merge branch 'main' of github.com:db-ui/mono into feat-nav-item-compo…
nmerget a3d0e47
fix: issue with brand logo
nmerget 55a7676
Merge remote-tracking branch 'origin/feat-nav-item-component' into fe…
nmerget e70fed7
fix: issue with vue navigation-item
nmerget 4af4f4a
Merge branch 'main' of github.com:db-ui/mono into feat-nav-item-compo…
nmerget 98052ad
chore: update screenshots
nmerget 044117a
chore: update snapshots
nmerget 247851c
Merge branch 'main' into feat-nav-item-component
mfranzke d3797a3
Merge branch 'main' into feat-nav-item-component
mfranzke 83075d6
fix: some issues from PR
nmerget 626502c
fix: removed additional functions in navigation-item
nmerget 6e59089
Merge branch 'main' into feat-nav-item-component
nmerget 68ae20d
fix: issue with wrong prop
nmerget a9dceb1
Merge branch 'main' into feat-nav-item-component
nmerget 8b9c2d6
Merge branch 'main' into feat-nav-item-component
nmerget 68e8500
Merge branch 'main' of github.com:db-ui/mono into feat-nav-item-compo…
nmerget de9b4ba
chore: update from main
nmerget e5fe031
Merge branch 'main' into feat-nav-item-component
nmerget File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
+532 Bytes
(100%)
...-match-screenshot-for-tonality-regular-and-color-neutral-0-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.27 KB
(100%)
...ld-match-screenshot-for-tonality-regular-and-color-neutral-0-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+599 Bytes
(100%)
...-match-screenshot-for-tonality-regular-and-color-neutral-0-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.4 KB
(100%)
...ld-match-screenshot-for-tonality-regular-and-color-neutral-0-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+587 Bytes
(100%)
...-match-screenshot-for-tonality-regular-and-color-neutral-0-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.07 KB
(100%)
...ld-match-screenshot-for-tonality-regular-and-color-neutral-0-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+502 Bytes
(100%)
...-match-screenshot-for-tonality-regular-and-color-neutral-0-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.44 KB
(100%)
...ld-match-screenshot-for-tonality-regular-and-color-neutral-0-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+519 Bytes
(100%)
...-match-screenshot-for-tonality-regular-and-color-neutral-0-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.45 KB
(100%)
...ld-match-screenshot-for-tonality-regular-and-color-neutral-0-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+826 Bytes
...pec.tsx-snapshots/DBNavigationItem-should-match-screenshot-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+826 Bytes
...sx-snapshots/DBNavigationItem-should-match-screenshot-1-mobile-chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+766 Bytes
...sx-snapshots/DBNavigationItem-should-match-screenshot-1-mobile-safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+766 Bytes
....spec.tsx-snapshots/DBNavigationItem-should-match-screenshot-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+605 Bytes
(100%)
...-match-screenshot-for-tonality-regular-and-color-neutral-0-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.12 KB
(100%)
...ld-match-screenshot-for-tonality-regular-and-color-neutral-0-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/components/overrides/angular/src/components/navigation-item/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { DBNavigationItem, DBNavigationItemModule } from './navigation-item'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,10 @@ | |
| * }]} | ||
| */ | ||
| const getComponents = () => [ | ||
| { | ||
| name: 'navigation-item' | ||
| }, | ||
|
|
||
| { | ||
| name: 'select' | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/components/src/components/navigation-item/docs/Angular.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| ## Angular | ||
|
|
||
| For general installation and configuration look at the [ngx-components](https://www.npmjs.com/package/@db-ui/ngx-components) package. | ||
|
|
||
| ### Load component | ||
|
|
||
| ```ts app.module.ts | ||
| //app.module.ts | ||
| import { DBNavigationItemModule } from '@db-ui/ngx-components'; | ||
|
|
||
| @NgModule({ | ||
| ... | ||
| imports: [..., DBNavigationItemModule], | ||
| ... | ||
| }) | ||
|
|
||
| ``` | ||
|
|
||
| ### Use component | ||
|
|
||
| ```html app.component.html | ||
| <!-- app.component.html --> | ||
| <a routerLink="mypath"> | ||
| <db-navigation-item>NavigationItem</db-navigation-item> | ||
| </a> | ||
| ``` |
17 changes: 17 additions & 0 deletions
17
packages/components/src/components/navigation-item/docs/HTML.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ## HTML | ||
|
|
||
| For general installation and configuration look at the [components](https://www.npmjs.com/package/@db-ui/components) package. | ||
|
|
||
| ### Use component | ||
|
|
||
| ```html index.html | ||
| <!-- index.html --> | ||
| ... | ||
| <body> | ||
| <a href="mypath"> | ||
| <div class="db-navigation-item"> | ||
| <button class="db-navigation-item-button">NavigationItem</button> | ||
| </div> | ||
| </a> | ||
| </body> | ||
| ``` | ||
8 changes: 8 additions & 0 deletions
8
packages/components/src/components/navigation-item/docs/Migration.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ## General | ||
|
|
||
| > **Note** | ||
| > For a general installation or migration process check out this [documentation](https://www.npmjs.com/package/@db-ui/components). | ||
|
|
||
| ## DB UI Core ➡ DB UI Components | ||
|
|
||
| New Component 🥳 |
19 changes: 19 additions & 0 deletions
19
packages/components/src/components/navigation-item/docs/React.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ## React | ||
|
|
||
| For general installation and configuration look at the [react-components](https://www.npmjs.com/package/@db-ui/react-components) package. | ||
|
|
||
| ### Use component | ||
|
|
||
| ```tsx App.tsx | ||
| // App.tsx | ||
| import { Link } from "react-router-dom"; | ||
| import { DBNavigationItem } from "@db-ui/react-components"; | ||
|
|
||
| const App = () => ( | ||
| <Link to="mypath"> | ||
| <DBNavigationItem>NavigationItem</DBNavigationItem> | ||
| </Link> | ||
| ); | ||
|
|
||
| export default App; | ||
| ``` |
18 changes: 18 additions & 0 deletions
18
packages/components/src/components/navigation-item/docs/Vue.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| ## Vue | ||
|
|
||
| For general installation and configuration look at the [v-components](https://www.npmjs.com/package/@db-ui/v-components) package. | ||
|
|
||
| ### Use component | ||
|
|
||
| ```vue App.vue | ||
| <!-- App.vue --> | ||
| <script> | ||
| import { DBNavigationItem } from "@db-ui/v-components"; | ||
| </script> | ||
|
|
||
| <template> | ||
| <router-link to="mypath"> | ||
| <DBNavigationItem>NavigationItem</DBNavigationItem> | ||
| </router-link> | ||
| </template> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default as DBNavigationItem } from './navigation-item'; |
47 changes: 47 additions & 0 deletions
47
packages/components/src/components/navigation-item/model.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { | ||
| ClickEventProps, | ||
| ClickEventState, | ||
| GlobalProps, | ||
| GlobalState, | ||
| IconAfterProps, | ||
| IconProps, | ||
| IconState, | ||
| WidthProps | ||
| } from '../../shared/model'; | ||
|
|
||
| export interface DBNavigationItemActionProps { | ||
| text?: string; | ||
| } | ||
|
|
||
| export interface DBNavigationItemDefaultProps { | ||
| /** | ||
| * Indicator for active navigation item (bold font). | ||
| */ | ||
| active?: boolean; | ||
|
|
||
| /** | ||
| * The disabled attribute can be set to [keep a user from clicking on the item](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#disabled). | ||
| */ | ||
| disabled?: boolean; | ||
|
|
||
| /** | ||
| * Use an icon button here for additional actions. | ||
| */ | ||
| action?: DBNavigationItemActionProps & IconProps & ClickEventProps; | ||
| } | ||
|
|
||
| export type DBNavigationItemProps = DBNavigationItemDefaultProps & | ||
| GlobalProps & | ||
| ClickEventProps & | ||
| IconProps & | ||
| IconAfterProps & | ||
| WidthProps; | ||
|
|
||
| export interface DBNavigationItemDefaultState { | ||
| handleActionClick: (event: any) => void; | ||
| } | ||
|
|
||
| export type DBNavigationItemState = DBNavigationItemDefaultState & | ||
| ClickEventState & | ||
| GlobalState & | ||
| IconState; |
1 change: 1 addition & 0 deletions
1
packages/components/src/components/navigation-item/navigation-item-web-component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @forward "navigation-item"; |
83 changes: 83 additions & 0 deletions
83
packages/components/src/components/navigation-item/navigation-item.lite.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { onMount, Show, useMetadata, useStore } from '@builder.io/mitosis'; | ||
| import { DBNavigationItemState, DBNavigationItemProps } from './model'; | ||
| import classNames from 'classnames'; | ||
| import { DBButton } from '../button'; | ||
|
|
||
| useMetadata({ | ||
| isAttachedToShadowDom: true, | ||
| component: { | ||
| // MS Power Apps | ||
| includeIcon: false, | ||
| properties: [] | ||
| } | ||
| }); | ||
|
|
||
| export default function DBNavigationItem(props: DBNavigationItemProps) { | ||
| // This is used as forwardRef | ||
| let component: any; | ||
| // jscpd:ignore-start | ||
| const state = useStore<DBNavigationItemState>({ | ||
| handleClick: (event: any) => { | ||
| if (props.onClick) { | ||
| props.onClick(event); | ||
| } | ||
| }, | ||
| handleActionClick: (event: any) => { | ||
| event.stopPropagation(); | ||
| if (props.action?.onClick) { | ||
| props.action.onClick(event); | ||
| } | ||
| event.preventDefault(); | ||
| }, | ||
| iconVisible: (icon?: string) => { | ||
| return Boolean(icon && icon !== '_' && icon !== 'none'); | ||
| }, | ||
| getClassNames: (...args: classNames.ArgumentArray) => { | ||
| return classNames(args); | ||
| } | ||
| }); | ||
|
|
||
| onMount(() => { | ||
| if (props.stylePath) { | ||
| state.stylePath = props.stylePath; | ||
| } | ||
| }); | ||
| // jscpd:ignore-end | ||
|
|
||
| return ( | ||
| <div | ||
| class={state.getClassNames('db-navigation-item', props.className)} | ||
| data-width={props.width}> | ||
| <button | ||
| class="db-navigation-item-button" | ||
| ref={component} | ||
| data-icon={ | ||
| state.iconVisible(props.icon) ? props.icon : undefined | ||
| } | ||
| data-icon-after={ | ||
| state.iconVisible(props.iconAfter) | ||
| ? props.iconAfter | ||
| : undefined | ||
| } | ||
| data-active={props.active} | ||
| data-width={props.width} | ||
| disabled={props.disabled} | ||
| onClick={(event) => state.handleClick(event)}> | ||
| <Show when={state.stylePath}> | ||
| <link rel="stylesheet" href={state.stylePath} /> | ||
| </Show> | ||
| {props.children} | ||
| </button> | ||
| <Show when={props.action}> | ||
| <DBButton | ||
| noText | ||
| variant="text" | ||
| icon={props.action.icon} | ||
| title={props.action.text || props.action.icon} | ||
| onClick={(event) => state.handleActionClick(event)}> | ||
| {props.action.text || props.action.icon} | ||
| </DBButton> | ||
| </Show> | ||
| </div> | ||
| ); | ||
| } |
51 changes: 51 additions & 0 deletions
51
packages/components/src/components/navigation-item/navigation-item.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| @use "@db-ui/foundations/build/scss/variables" as *; | ||
| @use "@db-ui/foundations/build/scss/variables.global" as *; | ||
| @use "@db-ui/foundations/build/scss/helpers/component" as *; | ||
| @use "@db-ui/foundations/build/scss/color/color-variants" as *; | ||
|
|
||
| .db-navigation-item { | ||
| display: inline-flex; | ||
|
|
||
| &[data-width="full"] { | ||
| width: 100%; | ||
| } | ||
| } | ||
|
|
||
| .db-navigation-item-button { | ||
| @extend %default-interactive-component; | ||
| @extend %default-background-transition; | ||
| @extend %bg-transparent-interactive; | ||
| @extend %transparent-border; | ||
|
|
||
| border-radius: $default-card-border-radius; | ||
| padding: $db-spacing-fixed-xs $db-spacing-fixed-sm; | ||
| white-space: nowrap; // we don't want to break | ||
| display: inline-flex; | ||
| justify-content: center; | ||
| text-align: center; | ||
| align-items: center; // Centering the content vertically and horizontally | ||
|
|
||
| &::before { | ||
| margin-inline-end: $db-spacing-fixed-sm; | ||
| } | ||
|
|
||
| &::after { | ||
| margin-inline-start: $db-spacing-fixed-sm; | ||
| } | ||
|
|
||
| &[data-active="true"] { | ||
| font-weight: 700; | ||
| } | ||
|
|
||
| &[data-width="full"] { | ||
| width: 100%; | ||
|
|
||
| &::after { | ||
| margin-inline-start: auto; | ||
| } | ||
| } | ||
|
|
||
| &:disabled { | ||
| opacity: $default-opacity; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.