Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
11001f4
feat: added component files for db-accordion
annsch Jul 26, 2023
911ac23
feat: accordion item
annsch Jul 26, 2023
2b6b283
feat: accordion item example for react
annsch Jul 28, 2023
8c56be9
Merge branch 'main' into feat-accordion-new
annsch Aug 3, 2023
a8b5f4c
docs: added docs for react and pure html
annsch Aug 3, 2023
a0bb808
fix: imports
annsch Aug 3, 2023
ed0cf8c
fix: resolve typeerror
annsch Aug 3, 2023
f2c956e
fix: routes.ts for patternhub
nmerget Aug 4, 2023
debacd5
Merge branch 'main' into feat-accordion-new
mfranzke Aug 10, 2023
cacb9c1
Update DBUI.cdsproj
mfranzke Aug 10, 2023
ab0805a
refactor: summary element even already has this role implicitly
mfranzke Aug 10, 2023
6e05168
refactor: optimization on the icon size
mfranzke Aug 10, 2023
11bfe66
feat: the border-radius is kind of special
mfranzke Aug 11, 2023
cfb1a1d
Merge branch 'main' into feat-accordion-new
mfranzke Aug 17, 2023
dd77ad2
Merge branch 'main' into feat-accordion-new
mfranzke Aug 21, 2023
adbc6b3
Merge branch 'main' into feat-accordion-new
mfranzke Aug 22, 2023
4548de5
Merge branch 'main' of github.com:db-ui/mono into feat-accordion-new
nmerget Aug 22, 2023
b5ec0be
feat: add accordion behaviour for angular an react
nmerget Aug 22, 2023
5b45fe4
Merge branch 'main' into feat-accordion-new
nmerget Aug 22, 2023
5fe7462
chore: update docs and snapshots
nmerget Aug 23, 2023
35e3538
Merge remote-tracking branch 'origin/feat-accordion-new' into feat-ac…
nmerget Aug 23, 2023
2261bc2
Merge branch 'main' into feat-accordion-new
mfranzke Aug 23, 2023
72eb35c
fix: issue with building showcase
nmerget Aug 23, 2023
1e8c59d
fix: issue with wrong active router link
nmerget Aug 23, 2023
e18b798
Merge branch 'main' into feat-accordion-new
nmerget Aug 23, 2023
10cc057
Merge branch 'main' into feat-accordion-new
mfranzke Aug 23, 2023
9a1a2db
fix: review feedback
annsch Aug 24, 2023
ab437f9
Merge branch 'main' into feat-accordion-new
annsch Aug 24, 2023
e0f57ca
fix: issue with wrong tonality icons
nmerget Aug 24, 2023
e0e67a6
Merge remote-tracking branch 'origin/feat-accordion-new' into feat-ac…
nmerget Aug 24, 2023
8ba6aa9
Merge branch 'main' into feat-accordion-new
nmerget Aug 24, 2023
d64b505
chore: update snapshots
nmerget Aug 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
4 changes: 4 additions & 0 deletions build-power-apps/DBUI/DBUI.cdsproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
</ItemGroup>

<ItemGroup>
<!-- <ProjectReference Include="..\accordion-item\DBAccordionItem.pcfproj" />

<ProjectReference Include="..\accordion\DBAccordion.pcfproj" /> -->

<ProjectReference Include="..\button\DBButton.pcfproj" />
<ProjectReference Include="..\icon\DBIcon.pcfproj" />
<ProjectReference Include="..\input\DBInput.pcfproj" />
Expand Down
13 changes: 10 additions & 3 deletions packages/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
</head>
<body style="padding: var(--db-spacing-fixed-md)">
<ul>
<li>
<a href="./src/components/badge/index.html">DBBadge</a>
</li>
<li>
<a href="./src/components/accordion-item/index.html">DBAccordionItem</a>
</li>

<li>
<a href="./src/components/accordion/index.html">DBAccordion</a>
</li>
<li>
<a href="./src/components/badge/index.html">DBBadge</a>
</li>

<li>
<a href="./src/fonts.html">Fonts</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DBAccordionItem, DBAccordionItemModule } from './accordion-item';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DBAccordion, DBAccordionModule } from './accordion';
19 changes: 19 additions & 0 deletions packages/components/scripts/post-build/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@
* }]}
*/
const getComponents = () => [
{
name: 'accordion-item'
},

{
name: 'accordion',
overwrites: {
angular: [
{ from: 'openItems = []', to: 'openItems: string[] = []' }
],
react: [
{
from: 'const ref = useRef<HTMLDivElement>(null);',
to: 'const ref = useRef<HTMLDivElement>(component);'
}
]
}
},

{
name: 'badge'
},
Expand Down
2 changes: 1 addition & 1 deletion packages/components/scripts/post-build/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = (tmp) => {
runReplacements(
[
{
from: 'immediate: true,',
from: /immediate: true,/g,
to: 'immediate: true,\nflush: "post"'
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@forward "accordion-item";
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {
onMount,
onUpdate,
Show,
Slot,
useMetadata,
useStore
} from '@builder.io/mitosis';
import { DBAccordionItemState, DBAccordionItemProps } from './model';
import { cls, uuid } from '../../utils';
import { DEFAULT_ID } from '../../shared/constants';

useMetadata({
isAttachedToShadowDom: true,
component: {
// MS Power Apps
includeIcon: false,
properties: []
}
});

export default function DBAccordionItem(props: DBAccordionItemProps) {
// This is used as forwardRef
let component: any;
// jscpd:ignore-start
const state = useStore<DBAccordionItemState>({
_id: DEFAULT_ID,
toggle: (event: any) => {
// We need this for react https://github.com/facebook/react/issues/15486#issuecomment-488028431
event?.preventDefault();
if (props.onToggle) {
props.onToggle(!props.open);
}
}
});

onMount(() => {
state._id = props.id || 'accordion-item-' + uuid();
if (props.stylePath) {
state.stylePath = props.stylePath;
}
});
// jscpd:ignore-end

return (
<details
ref={component}
id={state._id}
class={cls('db-accordion-item', props.className)}
aria-disabled={props.disabled}
open={props.open}>
<Show when={state.stylePath}>
<link rel="stylesheet" href={state.stylePath} />
</Show>
<summary onClick={(event) => state.toggle(event)}>
<Show when={props.title}>{props.title}</Show>
<Show when={!props.title}>
<Slot name="title" />
</Show>
</summary>
<div>
<Show when={props.content}>{props.content}</Show>
<Show when={!props.content}>{props.children}</Show>
</div>
</details>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@use "@db-ui/foundations/build/scss/variables" as *;
@use "@db-ui/foundations/build/scss/variables.global" as var;
@use "@db-ui/foundations/build/scss/helpers/functions" as functions;
@use "@db-ui/foundations/build/scss/icon/icons.helpers" as icons;
@use "@db-ui/foundations/build/scss/helpers/component" as component;
@use "@db-ui/foundations/build/scss/color/color-variants" as col-var;
@use "@db-ui/foundations/build/scss/animation/animations" as animations;
@use "../../styles/form-components" as form;

@mixin accordion-item-content() {
:not(summary):not(link) {
@content;
}
}

.db-accordion-item {
@extend %bg-transparent;
@include functions.divider($position: "top");

position: relative;
inline-size: 100%;

@include accordion-item-content() {
padding: var.$db-spacing-fixed-md;
padding-block-end: var.$db-spacing-fixed-lg;
}

&:last-of-type {
@include functions.divider($position: "bottom", $slot: "after");
}

&[aria-disabled="true"] {
pointer-events: none;
opacity: component.$default-opacity;
}

summary {
@extend %dropdown-icon;
@include col-var.bg-transparent-interactive(false);

list-style: none;
display: flex;
justify-content: space-between;
padding: var.$db-spacing-fixed-md;
gap: var.$db-spacing-fixed-md;

&::-webkit-details-marker {
display: none;
}

&::after {
inset-inline-end: var.$db-spacing-fixed-sm;
}

&:focus-visible {
// TODO: Evaluate whether this number is intended
border-radius: component.$default-border-radius + 2;
}
}

&[open] {
@include accordion-item-content() {
animation: accordion-open $db-transition-emotional-straight normal
both;
}

summary::after {
transform: form.$dropdown-icon-transform;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test, expect } from '@playwright/experimental-ct-react';
import AxeBuilder from '@axe-core/playwright';

import { DBAccordionItem } from './index';
// @ts-ignore - vue can only find it with .ts as file ending
import { DEFAULT_VIEWPORT } from '../../shared/constants.ts';

const comp = <DBAccordionItem title="Test">Test</DBAccordionItem>;

const testComponent = () => {
test('should contain text', async ({ mount }) => {
const component = await mount(comp);
await expect(component).toContainText('Test');
});

test('should match screenshot', async ({ mount }) => {
const component = await mount(comp);
await expect(component).toHaveScreenshot();
});
};

test.describe('DBAccordionItem', () => {
test.use({ viewport: DEFAULT_VIEWPORT });
testComponent();
});

test.describe('DBAccordionItem', () => {
test('should not have any A11y issues', async ({ page, mount }) => {
await mount(comp);
const accessibilityScanResults = await new AxeBuilder({ page })
.include('.db-accordion-item')
.analyze();

expect(accessibilityScanResults.violations).toEqual([]);
});
});
36 changes: 36 additions & 0 deletions packages/components/src/components/accordion-item/docs/Angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## 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 { DBAccordionItemModule } from '@db-ui/ngx-components';

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

```

### Use component

#### With Slots

```html app.component.html
<!-- app.component.html -->
<db-accordion-item>
<ng-container *title>Title</ng-container>
Content
</db-accordion-item>
```

#### With attributes

```html app.component.html
<!-- app.component.html -->
<db-accordion-item title="Title" content="Content"></db-accordion-item>
```
16 changes: 16 additions & 0 deletions packages/components/src/components/accordion-item/docs/HTML.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 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>
<details id="my_id" class="db-accordion-item">
<summary>Title</summary>
<div>Content</div>
</details>
</body>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## 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

### class

| Before | Status | After | Description |
| --------------- | :----: | ------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `cmp-accordion` | 🔁 | `db-accordion-item` | The old accordion was just 1 item, we split it to combine multiple accordion-items into 1 accordion (which is another component) |

### props

| Before | Status | After | Description |
| ---------- | :----: | ----------- | ----------------------------------------------------------- |
| `summary` | 🔁 | `title` | The title/summary of the details element. |
| `emphasis` | ❌ | ❌ | There is no emphasis anymore. |
| `size` | ❌ | ❌ | Controlled by the tonality. |
| | 🆕 | `disabled` | Disable the component. |
| | 🆕 | `content` | Pass in a simple string as fallback to normal children/slot |
| | 🆕 | `slotTitle` | Pass in a custom title (only required for React) |
25 changes: 25 additions & 0 deletions packages/components/src/components/accordion-item/docs/React.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## React

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

### Use component

#### With Slots

```tsx App.tsx
// App.tsx
import { DBAccordionItem } from "@db-ui/react-components";

const App = () => <DBAccordionItem slotTitle="Title">Content</DBAccordionItem>;
export default App;
```

#### With attributes

```tsx App.tsx
// App.tsx
import { DBAccordionItem } from "@db-ui/react-components";

const App = () => <DBAccordionItem title="Title" content="Content" />;
export default App;
```
34 changes: 34 additions & 0 deletions packages/components/src/components/accordion-item/docs/Vue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Vue

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

### Use component

#### With Slots

```vue App.vue
<!-- App.vue -->
<script>
import { DBAccordionItem } from "@db-ui/v-components";
</script>

<template>
<DBAccordionItem>
<template v-slot:title>Title</template>
Content
</DBAccordionItem>
</template>
```

#### With attributes

```vue App.vue
<!-- App.vue -->
<script>
import { DBAccordionItem } from "@db-ui/v-components";
</script>

<template>
<DBAccordionItem title="Title" content="Content"></DBAccordionItem>
</template>
```
Loading