Skip to content

Commit

Permalink
feat: align properties with figma to have a nearly 1:1 relationship (#…
Browse files Browse the repository at this point in the history
…3459)

* feat: align properties with figma to have a nearly 1:1 relationship

* fix: issue with showIcon

* fix: issue with showIcon

* fix: issue with vue output

* fix: issue with showIcon

* chore: update snapshots
  • Loading branch information
nmerget authored Dec 2, 2024
1 parent c168430 commit 19cabd0
Show file tree
Hide file tree
Showing 71 changed files with 320 additions and 125 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.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- link "Small arrow_right\" / \""
- link "Content arrow_up_right\" / \""
- link "(Default) Internal arrow_right\" / \""
- link "External arrow_up_right\" / \""
- link "External arrow_up_right\" / \""
- link "Show Icon"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- link "Small arrow_right\" / \""
- link "Content arrow_up_right\" / \""
- link "(Default) Internal arrow_right\" / \""
- link "External arrow_up_right\" / \""
- link "External arrow_up_right\" / \""
- link "Show Icon"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- link "Small arrow_right\" / \""
- link "Content arrow_up_right\" / \""
- link "(Default) Internal arrow_right\" / \""
- link "External arrow_up_right\" / \""
- link "External arrow_up_right\" / \""
- link "Show Icon"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- link "Small arrow_right\" / \""
- link "Content arrow_up_right\" / \""
- link "(Default) Internal arrow_right\" / \""
- link "External arrow_up_right\" / \""
- link "External arrow_up_right\" / \""
- link "Show Icon"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- link "Small arrow_right\" / \""
- link "Content arrow_up_right\" / \""
- link "(Default) Internal arrow_right\" / \""
- link "External arrow_up_right\" / \""
- link "External arrow_up_right\" / \""
- link "Show Icon"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- link "Small arrow_right\" / \""
- link "Content arrow_up_right\" / \""
- link "(Default) Internal arrow_right\" / \""
- link "External arrow_up_right\" / \""
- link "External arrow_up_right\" / \""
- link "Show Icon"
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: 2 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ npx playwright test --update-snapshots

You can also use `docker-compose` to test or regenerate screenshots.

- testing: `docker-compose -f ./e2e/docker-compose.yml up`
- update screenshots: `docker-compose -f ./e2e/docker-compose.regenerate.yml up`
- testing: `docker-compose -f ./e2e/docker-compose.yml up`
- update screenshots: `docker-compose -f ./e2e/docker-compose.regenerate.yml up`
5 changes: 5 additions & 0 deletions packages/components/scripts/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const runReplacements = (
replacements = [...replacements, ...component.overwrites.global];
}

replacements.push({
from: ',\n' + ',',
to: ','
});

for (const replacement of replacements) {
const option = {
files: file,
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/components/badge/badge.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
onMount,
onUpdate,
Show,
useMetadata,
useRef,
useStore
Expand Down Expand Up @@ -51,7 +52,9 @@ export default function DBBadge(props: DBBadgeProps) {
props.placement?.startsWith('corner') &&
(props.label ?? DEFAULT_LABEL)
}>
{props.children}
<Show when={props.text} else={props.children}>
{props.text}
</Show>
</span>
);
}
6 changes: 4 additions & 2 deletions packages/components/src/components/badge/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
GlobalState,
InitializedState,
SemanticProps,
SizeProps
SizeProps,
TextProps
} from '../../shared/model';

export const BadgePlacementList = [
Expand Down Expand Up @@ -34,7 +35,8 @@ export type DBBadgeProps = DBBadgeDefaultProps &
GlobalProps &
SemanticProps &
SizeProps &
EmphasisProps;
EmphasisProps &
TextProps;

export type DBBadgeDefaultState = {};

Expand Down
9 changes: 6 additions & 3 deletions packages/components/src/components/brand/brand.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { cls } from '../../utils';
import { Show, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { cls, getHideIcon } from '../../utils';
import { DBBrandProps, DBBrandState } from './model';
import { DEFAULT_ICON } from '../../shared/constants';

Expand All @@ -15,9 +15,12 @@ export default function DBBrand(props: DBBrandProps) {
<div
ref={ref}
data-icon={props.hideLogo ? 'none' : (props.icon ?? DEFAULT_ICON)}
data-hide-icon={getHideIcon(props.showIcon)}
id={props.id}
class={cls('db-brand', props.className)}>
{props.children}
<Show when={props.text} else={props.children}>
{props.text}
</Show>
</div>
);
}
16 changes: 13 additions & 3 deletions packages/components/src/components/brand/model.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { GlobalProps, GlobalState, IconProps } from '../../shared/model';
import {
GlobalProps,
GlobalState,
IconProps,
ShowIconProps,
TextProps
} from '../../shared/model';

export type DBBrandDefaultProps = {
/**
* Disable the default logo svg to pass in a custom `img`
* @deprecated: Disable the default logo svg to pass in a custom `img`
*/
hideLogo?: boolean;
};

export type DBBrandProps = DBBrandDefaultProps & GlobalProps & IconProps;
export type DBBrandProps = DBBrandDefaultProps &
GlobalProps &
IconProps &
ShowIconProps &
TextProps;

export type DBBrandDefaultState = {};

Expand Down
9 changes: 6 additions & 3 deletions packages/components/src/components/button/button.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { Show, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import type { DBButtonProps, DBButtonState } from './model';
import { cls, getBooleanAsString } from '../../utils';
import { cls, getBooleanAsString, getHideIcon } from '../../utils';
import { ClickEvent } from '../../shared/model';

useMetadata({});
Expand All @@ -27,6 +27,7 @@ export default function DBButton(props: DBButtonProps) {
disabled={props.disabled}
aria-label={props.label}
data-icon={props.icon}
data-hide-icon={getHideIcon(props.showIcon)}
data-size={props.size}
data-state={props.state}
data-width={props.width}
Expand All @@ -40,7 +41,9 @@ export default function DBButton(props: DBButtonProps) {
onClick={(event: ClickEvent<HTMLButtonElement>) =>
state.handleClick(event)
}>
{props.children}
<Show when={props.text} else={props.children}>
{props.text}
</Show>
</button>
);
}
6 changes: 5 additions & 1 deletion packages/components/src/components/button/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
GlobalProps,
GlobalState,
IconProps,
ShowIconProps,
SizeProps,
TextProps,
WidthProps
} from '../../shared/model';

Expand Down Expand Up @@ -79,7 +81,9 @@ export type DBButtonProps = DBButtonDefaultProps &
ClickEventProps<HTMLButtonElement> &
IconProps &
WidthProps &
SizeProps;
SizeProps &
ShowIconProps &
TextProps;

export type DBButtonDefaultState = {};

Expand Down
12 changes: 7 additions & 5 deletions packages/components/src/components/checkbox/checkbox.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
DEFAULT_VALID_MESSAGE_ID_SUFFIX
} from '../../shared/constants';
import { ChangeEvent, InteractionEvent } from '../../shared/model';
import { handleFrameworkEvent } from '../../utils/form-components';
import {
handleFrameworkEvent,
messageVisible
} from '../../utils/form-components';
import DBInfotext from '../infotext/infotext.lite';

useMetadata({});
Expand Down Expand Up @@ -167,13 +170,12 @@ export default function DBCheckbox(props: DBCheckboxProps) {
}
aria-describedby={state._descByIds}
/>
<Show when={props.label}>
<span>{props.label}</span>
<Show when={props.label} else={props.children}>
{props.label}
</Show>
{props.children}
</label>

<Show when={props.message}>
<Show when={messageVisible(props.message, props.showMessage)}>
<DBInfotext
size="small"
icon={props.messageIcon}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

border-width: form-components.$check-border-size;

&::before {
&:not([data-hide-icon-before="true"])::before {
align-content: center;
font-size: calc(
var(--db-icon-font-size) - 2 *
Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/components/icon/icon.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { Show, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import type { DBIconProps, DBIconState } from './model';
import { cls } from '../../utils';

Expand All @@ -20,7 +20,9 @@ export default function DBIcon(props: DBIconProps) {
data-icon-weight={props.weight}
data-icon-variant={props.variant}
aria-hidden="true">
{props.children}
<Show when={props.text} else={props.children}>
{props.text}
</Show>
</span>
);
}
12 changes: 10 additions & 2 deletions packages/components/src/components/icon/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { GlobalProps, GlobalState, IconProps } from '../../shared/model';
import {
GlobalProps,
GlobalState,
IconProps,
TextProps
} from '../../shared/model';

export const IconVariantList = ['default', 'inverted', 'filled'] as const;
export type IconVariantType = (typeof IconVariantList)[number];
Expand All @@ -11,7 +16,10 @@ export type DBIconDefaultProps = {
weight?: IconWeightType;
};

export type DBIconProps = DBIconDefaultProps & GlobalProps & IconProps;
export type DBIconProps = DBIconDefaultProps &
GlobalProps &
IconProps &
TextProps;

export type DBIconDefaultState = {};

Expand Down
11 changes: 7 additions & 4 deletions packages/components/src/components/infotext/infotext.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { Show, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { DBInfotextProps, DBInfotextState } from './model';
import { cls } from '../../utils';
import { cls, getHideIcon } from '../../utils';

useMetadata({});

Expand All @@ -18,8 +18,11 @@ export default function DBInfotext(props: DBInfotextProps) {
class={cls('db-infotext', props.className)}
data-icon={props.icon}
data-semantic={props.semantic}
data-size={props.size}>
{props.children}
data-size={props.size}
data-hide-icon-after={getHideIcon(props.showIcon ?? true)}>
<Show when={props.text} else={props.children}>
{props.text}
</Show>
</span>
);
}
8 changes: 6 additions & 2 deletions packages/components/src/components/infotext/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {
GlobalState,
IconProps,
SemanticProps,
SizeProps
ShowIconProps,
SizeProps,
TextProps
} from '../../shared/model';

export type DBInfotextDefaultProps = {};
Expand All @@ -12,7 +14,9 @@ export type DBInfotextProps = DBInfotextDefaultProps &
GlobalProps &
SemanticProps &
IconProps &
SizeProps;
SizeProps &
ShowIconProps &
TextProps;

export type DBInfotextDefaultState = {};

Expand Down
20 changes: 16 additions & 4 deletions packages/components/src/components/input/input.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import {
useStore,
useTarget
} from '@builder.io/mitosis';
import { cls, delay, hasVoiceOver, isArrayOfStrings, uuid } from '../../utils';
import {
cls,
delay,
getHideIcon,
hasVoiceOver,
isArrayOfStrings,
uuid
} from '../../utils';
import { DBInputProps, DBInputState } from './model';
import {
DEFAULT_DATALIST_ID_SUFFIX,
Expand All @@ -27,7 +34,10 @@ import {
ValueLabelType
} from '../../shared/model';
import DBInfotext from '../infotext/infotext.lite';
import { handleFrameworkEvent } from '../../utils/form-components';
import {
handleFrameworkEvent,
messageVisible
} from '../../utils/form-components';

useMetadata({});

Expand Down Expand Up @@ -161,8 +171,10 @@ export default function DBInput(props: DBInputProps) {
<div
class={cls('db-input', props.className)}
data-variant={props.variant}
data-hide-icon={getHideIcon(props.showIcon)}
data-icon={props.icon}
data-icon-after={props.iconAfter}>
data-icon-after={props.iconAfter}
data-hide-icon-after={getHideIcon(props.showIcon)}>
<label htmlFor={state._id}>{props.label ?? DEFAULT_LABEL}</label>
<input
aria-invalid={props.customValidity === 'invalid'}
Expand Down Expand Up @@ -217,7 +229,7 @@ export default function DBInput(props: DBInputProps) {
</datalist>
</Show>
{props.children}
<Show when={props.message}>
<Show when={messageVisible(props.message, props.showMessage)}>
<DBInfotext
size="small"
icon={props.messageIcon}
Expand Down
Loading

0 comments on commit 19cabd0

Please sign in to comment.