Skip to content

Commit

Permalink
Merge branch 'main' into fix-patternhub-next-previous
Browse files Browse the repository at this point in the history
  • Loading branch information
mfranzke authored Nov 19, 2024
2 parents 69d01e7 + 386de47 commit 94bef43
Show file tree
Hide file tree
Showing 47 changed files with 1,187 additions and 74 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.
4 changes: 4 additions & 0 deletions packages/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
</head>
<body style="padding: var(--db-spacing-fixed-md)">
<ul>
<li>
<a href="./src/components/stack/index.html">DBStack</a>
</li>

<li>
<a href="./src/components/switch/index.html">DBSwitch</a>
</li>
Expand Down
3 changes: 3 additions & 0 deletions packages/components/scripts/post-build/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export type Component = {
};

export const getComponents = (): Component[] => [
{
name: 'stack'
},
{
name: 'switch',
overwrites: {
Expand Down
28 changes: 28 additions & 0 deletions packages/components/src/components/stack/docs/Angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## 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.component.ts
// app.component.ts
import { DBStack } from '@db-ui/ngx-components';

@Component({
// ...
standalone: true,
imports: [..., DBStack],
// ...
})
```

### Use component

```html app.component.html
<!-- app.component.html -->
<db-stack>
<span>Test 1</span>
<span>Test 2</span>
<span>Test 3</span>
</db-stack>
```
17 changes: 17 additions & 0 deletions packages/components/src/components/stack/docs/HTML.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## 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-stack">
<span>Test 1</span>
<span>Test 2</span>
<span>Test 3</span>
</div>
</body>
```
8 changes: 8 additions & 0 deletions packages/components/src/components/stack/docs/Migration.md
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 🥳
20 changes: 20 additions & 0 deletions packages/components/src/components/stack/docs/React.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## React

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

### Use component

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

const App = () => (
<DBStack>
<span>Test 1</span>
<span>Test 2</span>
<span>Test 3</span>
</DBStack>
);

export default App;
```
20 changes: 20 additions & 0 deletions packages/components/src/components/stack/docs/Vue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Vue

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

### Use component

```vue App.vue
<!-- App.vue -->
<script>
import { DBStack } from "@db-ui/v-components";
</script>
<template>
<DBStack>
<span>Test 1</span>
<span>Test 2</span>
<span>Test 3</span>
</DBStack>
</template>
```
11 changes: 11 additions & 0 deletions packages/components/src/components/stack/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>DBStack</title>
<link rel="stylesheet" href="/styles/db-ui-42.css" />
</head>
<body style="padding: var(--db-spacing-fixed-md)">
<div class="db-stack">Test</div>
</body>
</html>
1 change: 1 addition & 0 deletions packages/components/src/components/stack/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as DBStack } from './stack';
52 changes: 52 additions & 0 deletions packages/components/src/components/stack/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { GapSpacingProps, GlobalProps, GlobalState } from '../../shared/model';

export const StackVariantList = ['simple', 'divider'] as const;
export type StackVariantType = (typeof StackVariantList)[number];

export const StackDirectionList = ['row', 'column'] as const;
export type StackDirectionType = (typeof StackDirectionList)[number];

export const StackAlignmentList = [
'stretch',
'start',
'end',
'center'
] as const;
export type StackAlignmentType = (typeof StackAlignmentList)[number];

export const StackJustifyContentList = [
'space-between',
'start',
'end',
'center'
] as const;
export type StackJustifyContentType = (typeof StackJustifyContentList)[number];

export type DBStackDefaultProps = {
/**
* Change variant of stack. To use variant="divider" add a DBDivider after each element
*/
variant?: StackVariantType;
/**
* Set the direction of the stack. Defaults to "column"
*/
direction?: StackDirectionType;
/**
* If the stack should wrap if parent is too small otherwise you get an overflow
*/
wrap?: boolean;
/**
* Represents css align-items
*/
alignment?: StackAlignmentType;
/**
* Represents css justify-content
*/
justifyContent?: StackJustifyContentType;
};

export type DBStackProps = DBStackDefaultProps & GlobalProps & GapSpacingProps;

export type DBStackDefaultState = {};

export type DBStackState = DBStackDefaultState & GlobalState;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@forward "stack";
28 changes: 28 additions & 0 deletions packages/components/src/components/stack/stack.lite.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Show, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { DBStackState, DBStackProps } from './model';
import { cls, getBooleanAsString } from '../../utils';

useMetadata({});

export default function DBStack(props: DBStackProps) {
// This is used as forwardRef
const ref = useRef<HTMLDivElement>(null);
// jscpd:ignore-start
const state = useStore<DBStackState>({});
// jscpd:ignore-end

return (
<div
ref={ref}
id={props.id}
class={cls('db-stack', props.className)}
data-gap={props.gap}
data-variant={props.variant}
data-direction={props.direction}
data-alignment={props.alignment}
data-justify-content={props.justifyContent}
data-wrap={getBooleanAsString(props.wrap)}>
{props.children}
</div>
);
}
5 changes: 5 additions & 0 deletions packages/components/src/components/stack/stack.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use "../../styles/stack-components";

.db-stack {
@extend %default-stack;
}
43 changes: 43 additions & 0 deletions packages/components/src/components/stack/stack.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { test, expect } from '@playwright/experimental-ct-react';
import AxeBuilder from '@axe-core/playwright';

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

const comp: any = (
<DBStack>
<span>Test</span>
<span>Test 2</span>
<span>Test 3</span>
</DBStack>
);

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();
});
};

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

expect(accessibilityScanResults.violations).toEqual([]);
});
};

test.describe('DBStack', () => {
test.use({ viewport: DEFAULT_VIEWPORT });
testComponent();
testA11y();
});
1 change: 1 addition & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ export * from './shared/icon-types';
export * from './shared/model';
export * from './utils/index';
export * from './utils/navigation';
export * from './components/stack';
20 changes: 20 additions & 0 deletions packages/components/src/shared/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ export type GapProps = {
gap?: boolean;
};

export const GapSpacingList = [
'none',
'3x-large',
'2x-large',
'x-large',
'large',
'medium',
'small',
'x-small',
'2x-small',
'3x-small'
] as const;
export type GapSpacingType = (typeof GapSpacingList)[number];
export type GapSpacingProps = {
/**
* Set the gap/spacing between elements
*/
gap?: GapSpacingType;
};

export type OverflowProps = {
/**
* The overflow attribute sets a max-width and longer text will be dotted.
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/styles/_custom-elements.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$custom-elements: // angular-workaround
db-stack, db-switch, db-tab-panel, db-tabs, db-tab-list, db-tab-item,
db-tab-bar, db-tooltip, db-popover, db-textarea, db-navigation,
db-accordion-item, db-accordion, db-badge, db-navigation-item, db-tag,
db-radio, db-select, db-notification, db-codedocs, db-brand, db-button,
db-card, db-checkbox, db-divider, db-drawer, db-header, db-icon, db-infotext,
db-input, db-link, db-page, db-section, db-tab, db-tabbar;
Loading

0 comments on commit 94bef43

Please sign in to comment.