Skip to content

Commit

Permalink
feat: add tab component (#2067)
Browse files Browse the repository at this point in the history
* feat: add tab component

* feat: added content section

- added content section (icon trailing, leading, only icon)
- index.html needs to be adjusted accordingly
- only icon styling not done yet

* feat: added behavior and content alignment

* feat: adjusted index.html

* feat: articles show when inputs checked

* feat: adjusted html file

* feat: tab-bar in html

started first styling

* feat: tab-bar html

* feat: add tabs, tab-list, tab-panel

* feat: add tabs for all frameworks

* fix: linting issues

* chore: update screenshots

* chore: update background for tab puls

* fix: linting issues

* fix: issues for patternhub build

* fix: issues with pipeline

* chore: update snapshots

* chore: update angular showcase tabs title

* chore: update tabs divider to work with overflow

* chore: update snapshots

* chore: update snapshots

* fix: issue for angular

* chore: update from main

* chore: update from main

* Update index.html

---------

Co-authored-by: NicolasMerget <[email protected]>
Co-authored-by: Nicolas Merget <[email protected]>
Co-authored-by: Maximilian Franzke <[email protected]>
  • Loading branch information
4 people authored Feb 19, 2024
1 parent e16dcfa commit 704095c
Show file tree
Hide file tree
Showing 137 changed files with 2,384 additions and 313 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions packages/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
<head>
<meta charset="UTF-8" />
<title>Dev</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="/styles/db-ui-42.css" />
</head>
<body style="padding: var(--db-spacing-fixed-md)">
<ul>
<li>
<a href="./src/components/tabs/index.html">DBTabs</a>
</li>

<li>
<a href="./src/components/tab/index.html">DBTab</a>
</li>

<li>
<a href="./src/components/tooltip/index.html">DBTooltip</a>
</li>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DBTabList } from './tab-list';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DBTabPanel } from './tab-panel';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DBTabs } from './tabs';
9 changes: 9 additions & 0 deletions packages/components/scripts/post-build/angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ module.exports = (tmp) => {
}
];

if (component.config?.angular?.initValues) {
component.config?.angular?.initValues.forEach((init) => {
replacements.push({
from: `["${init.key}"];`,
to: `["${init.key}"] = ${init.value === '' ? '""' : init.value};`
});
});
}

if (component.config?.angular?.controlValueAccessor) {
setControlValueAccessorReplacements(
replacements,
Expand Down
48 changes: 41 additions & 7 deletions packages/components/scripts/post-build/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* },
* angular?: {
* controlValueAccessor?: string,
* directives?: {name:string, ngContentName?:string}[]
* directives?: {name:string, ngContentName?:string}[],
* initValues?: {key:string, value:any}[]
* },
* react?: {
* propsPassingFilter?: string[];
Expand All @@ -23,6 +24,45 @@
* }]}
*/
const getComponents = () => [
{
name: 'tab-panel',
config: {
angular: {
initValues: [
{ key: 'name', value: '' },
{ key: 'index', value: 0 }
]
}
}
},
{
name: 'tab',
config: {
angular: {
initValues: [
{ key: 'name', value: '' },
{ key: 'index', value: 0 }
]
}
}
},

{
name: 'tabs',
overwrites: {
angular: [
{
from: 'scrollContainer = null;',
to: 'scrollContainer: Element | null = null;'
}
]
}
},

{
name: 'tab-list'
},

{
name: 'tooltip'
},
Expand Down Expand Up @@ -233,12 +273,6 @@ const getComponents = () => [
{
name: 'card'
},
{
name: 'tab-bar'
},
{
name: 'tab'
},
{
name: 'button'
},
Expand Down
12 changes: 8 additions & 4 deletions packages/components/src/components/accordion/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { GlobalProps, GlobalState, InitializedState } from '../../shared/model';
import {
GlobalProps,
GlobalState,
InitializedState,
ItemClickState
} from '../../shared/model';
import { DBAccordionItemDefaultProps } from '../accordion-item/model';

export interface DBAccordionItemInterface
Expand Down Expand Up @@ -28,12 +33,11 @@ export interface DBAccordionDefaultProps {
export type DBAccordionProps = DBAccordionDefaultProps & GlobalProps;

export interface DBAccordionDefaultState {
clickedId: string;
openItems: string[];
handleItemClick: (id: string) => void;
convertItems: (items?: any[] | string) => DBAccordionItemInterface[];
}

export type DBAccordionState = DBAccordionDefaultState &
GlobalState &
InitializedState;
InitializedState &
ItemClickState;
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

&[aria-current="page"] {
// add puls for main-navigation items
@extend %show-db-puls;
@extend %show-db-puls-auto;

menu {
// hide puls for non main-navigation items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
useRef,
useStore
} from '@builder.io/mitosis';
import { DBNavigationItemState, DBNavigationItemProps } from './model';
import { DBNavigationItemProps, DBNavigationItemState } from './model';
import { DBButton } from '../button';
import { cls, uuid } from '../../utils';
import { cls, uuid, visibleInVX, visibleInVY } from '../../utils';
import { DEFAULT_BACK } from '../../shared/constants';
import { ClickEvent } from '../../shared/model';

Expand Down Expand Up @@ -63,10 +63,23 @@ export default function DBNavigationItem(props: DBNavigationItemProps) {
const subNavigationSlot = document?.getElementById(
state.subNavigationId
) as HTMLMenuElement;

if (subNavigationSlot) {
const children = subNavigationSlot.children;
if (children?.length > 0) {
state.hasAreaPopup = true;
if (!visibleInVX(subNavigationSlot)) {
subNavigationSlot.setAttribute(
'data-outside-vx',
'true'
);
}
if (!visibleInVY(subNavigationSlot)) {
subNavigationSlot.setAttribute(
'data-outside-vy',
'true'
);
}
} else {
state.hasSubNavigation = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

.db-navigation-item {
--db-has-before: 0;
@extend %db-puls;
@extend %db-puls-auto;

@include icon-passing.icon-passing();

Expand Down Expand Up @@ -183,6 +183,11 @@

transition: visibility 1ms linear; // workaround to enable focus with keyboard

&[data-outside-vx="true"] {
transform: translateX(-100%);
inset-inline-start: 100%;
}

&:hover,
&:focus-within {
visibility: visible;
Expand All @@ -209,8 +214,27 @@
);
inset-inline-start: calc(100% + #{variables.$db-spacing-fixed-xs});

&[data-outside-vy="true"] {
inset-block-start: calc(
100% + #{variables.$db-spacing-fixed-md}
);
transform: translateY(-100%);
}

&[data-outside-vx="true"] {
transform: translateX(-100%);
inset-inline-start: calc(
-1 * #{variables.$db-spacing-fixed-xs}
);

&[data-outside-vy="true"] {
transform: translate(-100%, -100%);
}
}

&::before {
content: "";
position: absolute;
padding: variables.$db-spacing-fixed-xs;
// #{$db-spacing-fixed-3xs} for box shadow
inset-block-start: #{variables.$db-spacing-fixed-3xs};
Expand All @@ -220,6 +244,17 @@
block-size: 100%;
inline-size: variables.$db-spacing-fixed-xs;
}

&::after {
content: "";
position: absolute;
padding: variables.$db-spacing-fixed-xs;
// #{$db-spacing-fixed-3xs} for box shadow
inset-block-start: #{variables.$db-spacing-fixed-3xs};
inset-inline-end: calc(-1 *#{variables.$db-spacing-fixed-xs});
block-size: 100%;
inline-size: variables.$db-spacing-fixed-xs;
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions packages/components/src/components/tab-bar/docs/Angular.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/components/src/components/tab-bar/docs/HTML.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/components/src/components/tab-bar/docs/React.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/components/src/components/tab-bar/docs/Vue.md

This file was deleted.

1 change: 0 additions & 1 deletion packages/components/src/components/tab-bar/index.ts

This file was deleted.

18 changes: 0 additions & 18 deletions packages/components/src/components/tab-bar/model.ts

This file was deleted.

This file was deleted.

65 changes: 0 additions & 65 deletions packages/components/src/components/tab-bar/tab-bar.lite.tsx

This file was deleted.

Empty file.
26 changes: 26 additions & 0 deletions packages/components/src/components/tab-list/docs/Angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Angular

For general installation and configuration take a 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 { DBTabListModule } from '@db-ui/ngx-components';

@NgModule({
...
imports: [..., DBTabListModule],
...
})

```

### Use component

```html app.component.html
<!-- app.component.html -->
<db-tab-list>TabList</db-tab-list>
```


16 changes: 16 additions & 0 deletions packages/components/src/components/tab-list/docs/HTML.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## HTML

For general installation and configuration take a look at the [components](https://www.npmjs.com/package/@db-ui/components) package.

### Use component

```html index.html
<!-- index.html -->
...
<body>
<div class="db-tab-list">
TabList
</div>
</body>
```

Loading

0 comments on commit 704095c

Please sign in to comment.