Skip to content
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

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
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.
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.
nmerget marked this conversation as resolved.
Show resolved Hide resolved
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.
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ export default function DBAccordionItem(props: DBAccordionItemProps) {
</Show>
</summary>
<div>
<Show when={props.content}>{props.content}</Show>
<Show when={!props.content}>{props.children}</Show>
<Show when={props.content} else={props.children}>
{props.content}
</Show>
</div>
</details>
);
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>
nmerget marked this conversation as resolved.
Show resolved Hide resolved
</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
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
4 changes: 3 additions & 1 deletion packages/components/src/components/input/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
IconProps,
InputEventProps,
InputEventState,
ShowIconProps,
ValueLabelType
} from '../../shared/model';

Expand Down Expand Up @@ -77,7 +78,8 @@ export type DBInputProps = DBInputDefaultProps &
FormProps &
IconProps &
IconAfterProps &
FormMessageProps;
FormMessageProps &
ShowIconProps;

export type DBInputDefaultState = {
_dataListId?: string;
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/components/link/link.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Show, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { DBLinkProps, DBLinkState } from './model';
import { cls, getBooleanAsString } from '../../utils';
import { cls, getBooleanAsString, getHideIcon } from '../../utils';
import { ClickEvent } from '../../shared/model';
import { DEFAULT_ID } from '../../shared/constants';

Expand Down Expand Up @@ -38,15 +38,15 @@ export default function DBLink(props: DBLinkProps) {
aria-label={props.label}
aria-current={props.current}
data-size={props.size}
data-hide-icon-after={getHideIcon(props.showIcon ?? true)}
data-variant={props.variant}
data-content={props.content || 'internal'}
onClick={(event: ClickEvent<HTMLAnchorElement>) =>
state.handleClick(event)
}>
<Show when={props.text}>
<span>{props.text}</span>
<Show when={props.text} else={props.children}>
{props.text}
</Show>
{props.children}
</a>
);
}
16 changes: 7 additions & 9 deletions packages/components/src/components/link/link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
@extend %db-link-height;
}

&:not([data-variant="inline"]) {
&[data-content="internal"] {
@include icons.set-icon("arrow_right", "after");
&[data-content="internal"] {
@include icons.set-icon("arrow_right", "after");

&::after {
vertical-align: top;
}
&::after {
vertical-align: top;
}
}

&[data-content="external"] {
@include icons.set-icon("arrow_up_right", "after");
}
&[data-content="external"] {
@include icons.set-icon("arrow_up_right", "after");
}

&[data-content="internal"],
Expand Down
Loading
Loading