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 figma properties alignment breaking #3465

Draft
wants to merge 1 commit into
base: feat-figma-properties-alignment
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions docs/migration/v0.4.x-to-v0.5.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Migration Beta (0.4.x) ➡ Beta (0.5.x)

No breaking changes
18 changes: 18 additions & 0 deletions docs/migration/v0.5.x-to-v0.6.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Migration Beta (0.5.x) ➡ Beta (0.6.x)

### Components

We changed some properties for components to align with Figma properties:

#### Accordion-Item

- `content` ➡️ `text`

#### Notification

- `behaviour="closeable|permanent"` ➡️ `closeable="true/false"`- Defaults to `false`

#### Form-Components (Input, Select, Checkbox, Radio, Switch, Textarea)

- `variant="hidden"` ➡️ `showLabel="true/false"` - Defaults to `true`
- `customValidity` ➡️ `validation`
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export default function DBAccordionItem(props: DBAccordionItemProps) {
</Show>
</summary>
<div>
<Show when={props.content} else={props.children}>
{props.content}
<Show when={props.text} else={props.children}>
{props.text}
</Show>
</div>
</details>
Expand Down
8 changes: 3 additions & 5 deletions packages/components/src/components/accordion-item/model.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {
GlobalProps,
GlobalState,
TextProps,
ToggleEventProps,
ToggleEventState
} from '../../shared/model';

export type DBAccordionItemDefaultProps = {
/**
* Alternative for passing only a string instead of children
*/
content?: string;
/**
* Initial state for the accordion item
*/
Expand All @@ -34,7 +31,8 @@ export type DBAccordionItemDefaultProps = {

export type DBAccordionItemProps = DBAccordionItemDefaultProps &
GlobalProps &
ToggleEventProps;
ToggleEventProps &
TextProps;

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

Expand All @@ -15,7 +15,7 @@ export default function DBBrand(props: DBBrandProps) {
<div
ref={ref}
data-icon={props.hideLogo ? 'none' : (props.icon ?? DEFAULT_ICON)}
data-hide-icon={getHideIcon(props.showIcon)}
data-hide-icon={getHideProp(props.showIcon)}
id={props.id}
class={cls('db-brand', props.className)}>
<Show when={props.text} else={props.children}>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/components/button/button.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 type { DBButtonProps, DBButtonState } from './model';
import { cls, getBooleanAsString, getHideIcon } from '../../utils';
import { cls, getBooleanAsString, getHideProp } from '../../utils';
import { ClickEvent } from '../../shared/model';

useMetadata({});
Expand All @@ -27,7 +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-hide-icon={getHideProp(props.showIcon)}
data-size={props.size}
data-state={props.state}
data-width={props.width}
Expand Down
19 changes: 13 additions & 6 deletions packages/components/src/components/checkbox/checkbox.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import {
useTarget
} from '@builder.io/mitosis';
import { DBCheckboxProps, DBCheckboxState } from './model';
import { cls, delay, hasVoiceOver, uuid } from '../../utils';
import {
cls,
delay,
getBooleanAsString,
getHideProp,
hasVoiceOver,
uuid
} from '../../utils';
import {
DEFAULT_INVALID_MESSAGE,
DEFAULT_INVALID_MESSAGE_ID_SUFFIX,
Expand Down Expand Up @@ -51,7 +58,7 @@ export default function DBCheckbox(props: DBCheckboxProps) {
});

/* For a11y reasons we need to map the correct message with the checkbox */
if (!ref?.validity.valid || props.customValidity === 'invalid') {
if (!ref?.validity.valid || props.validation === 'invalid') {
state._descByIds = state._invalidMessageId;
if (hasVoiceOver()) {
state._voiceOverFallback =
Expand All @@ -61,7 +68,7 @@ export default function DBCheckbox(props: DBCheckboxProps) {
delay(() => (state._voiceOverFallback = ''), 1000);
}
} else if (
props.customValidity === 'valid' ||
props.validation === 'valid' ||
(ref?.validity.valid && props.required)
) {
state._descByIds = state._validMessageId;
Expand Down Expand Up @@ -146,11 +153,11 @@ export default function DBCheckbox(props: DBCheckboxProps) {
<div
class={cls('db-checkbox', props.className)}
data-size={props.size}
data-variant={props.variant}>
data-hide-label={getHideProp(props.showLabel)}>
<label htmlFor={state._id}>
<input
aria-invalid={props.customValidity === 'invalid'}
data-custom-validity={props.customValidity}
aria-invalid={props.validation === 'invalid'}
data-custom-validity={props.validation}
ref={ref}
type="checkbox"
id={state._id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Show, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { DBInfotextProps, DBInfotextState } from './model';
import { cls, getHideIcon } from '../../utils';
import { cls, getHideProp } from '../../utils';

useMetadata({});

Expand All @@ -19,7 +19,7 @@ export default function DBInfotext(props: DBInfotextProps) {
data-icon={props.icon}
data-semantic={props.semantic}
data-size={props.size}
data-hide-icon-after={getHideIcon(props.showIcon ?? true)}>
data-hide-icon-after={getHideProp(props.showIcon ?? true)}>
<Show when={props.text} else={props.children}>
{props.text}
</Show>
Expand Down
16 changes: 9 additions & 7 deletions packages/components/src/components/input/input.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
import {
cls,
delay,
getHideIcon,
getBooleanAsString,
getHideProp,
hasVoiceOver,
isArrayOfStrings,
uuid
Expand Down Expand Up @@ -77,7 +78,7 @@ export default function DBInput(props: DBInputProps) {
});

/* For a11y reasons we need to map the correct message with the input */
if (!ref?.validity.valid || props.customValidity === 'invalid') {
if (!ref?.validity.valid || props.validation === 'invalid') {
state._descByIds = state._invalidMessageId;
if (hasVoiceOver()) {
state._voiceOverFallback =
Expand All @@ -87,7 +88,7 @@ export default function DBInput(props: DBInputProps) {
delay(() => (state._voiceOverFallback = ''), 1000);
}
} else if (
props.customValidity === 'valid' ||
props.validation === 'valid' ||
(ref?.validity.valid &&
(props.required ||
props.minLength ||
Expand Down Expand Up @@ -171,14 +172,15 @@ export default function DBInput(props: DBInputProps) {
<div
class={cls('db-input', props.className)}
data-variant={props.variant}
data-hide-icon={getHideIcon(props.showIcon)}
data-hide-label={getHideProp(props.showLabel)}
data-hide-icon={getHideProp(props.showIcon)}
data-icon={props.icon}
data-icon-after={props.iconAfter}
data-hide-icon-after={getHideIcon(props.showIcon)}>
data-hide-icon-after={getHideProp(props.showIcon)}>
<label htmlFor={state._id}>{props.label ?? DEFAULT_LABEL}</label>
<input
aria-invalid={props.customValidity === 'invalid'}
data-custom-validity={props.customValidity}
aria-invalid={props.validation === 'invalid'}
data-custom-validity={props.validation}
ref={ref}
id={state._id}
name={props.name}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $icon-padding: calc(
--db-form-component-padding-inline-end: #{$icon-padding};
}

&[data-variant="hidden"] {
&[data-hide-label="true"] {
--db-label-visible-height: 0;
--db-label-visible-spacing: 1;
}
Expand Down
4 changes: 2 additions & 2 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, getHideIcon } from '../../utils';
import { cls, getBooleanAsString, getHideProp } from '../../utils';
import { ClickEvent } from '../../shared/model';
import { DEFAULT_ID } from '../../shared/constants';

Expand Down Expand Up @@ -38,7 +38,7 @@ 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-hide-icon-after={getHideProp(props.showIcon ?? true)}
data-variant={props.variant}
data-content={props.content || 'internal'}
onClick={(event: ClickEvent<HTMLAnchorElement>) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@builder.io/mitosis';
import { DBNavigationItemProps, DBNavigationItemState } from './model';
import DBButton from '../button/button.lite';
import { cls, getBooleanAsString, getHideIcon, uuid } from '../../utils';
import { cls, getBooleanAsString, getHideProp, uuid } from '../../utils';
import { NavigationItemSafeTriangle } from '../../utils/navigation';
import { DEFAULT_BACK } from '../../shared/constants';
import { ClickEvent } from '../../shared/model';
Expand Down Expand Up @@ -97,7 +97,7 @@ export default function DBNavigationItem(props: DBNavigationItemProps) {
class={cls('db-navigation-item', props.className)}
data-width={props.width}
data-icon={props.icon}
data-hide-icon={getHideIcon(props.showIcon)}
data-hide-icon={getHideProp(props.showIcon)}
data-active={props.active}
aria-disabled={getBooleanAsString(props.disabled)}>
<Show when={!state.hasSubNavigation}>
Expand Down
8 changes: 2 additions & 6 deletions packages/components/src/components/notification/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export const NotificationAriaLiveList = ['assertive', 'polite', 'off'] as const;
export type NotificationAriaLiveType =
(typeof NotificationAriaLiveList)[number];

export const NotificationBehaviourList = ['closable', 'permanent'] as const;
export type NotificationBehaviourType =
(typeof NotificationBehaviourList)[number];

export type DBNotificationDefaultProps = {
/**
* The arialive attribute will lead to that the screenreader interrupts immediately
Expand All @@ -39,9 +35,9 @@ export type DBNotificationDefaultProps = {
ariaLive?: NotificationAriaLiveType;

/**
* The behaviour attribute shows/hides the close button on the top right.
* The closeable attribute shows/hides the close button on the top right.
*/
behaviour?: NotificationBehaviourType;
closeable?: boolean;

/**
* The headline attribute changes the text of the bold headline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Show, Slot, useMetadata, useRef, useStore } from '@builder.io/mitosis';
import { DBNotificationProps, DBNotificationState } from './model';
import DBButton from '../button/button.lite';
import { DEFAULT_CLOSE_BUTTON } from '../../shared/constants';
import { cls, getHideIcon } from '../../utils';
import { cls, getHideProp } from '../../utils';
import { ClickEvent } from '../../shared/model';

useMetadata({});
Expand All @@ -28,7 +28,7 @@ export default function DBNotification(props: DBNotificationProps) {
data-semantic={props.semantic}
data-variant={props.variant}
data-icon={props.icon}
data-hide-icon={getHideIcon(props.showIcon)}
data-hide-icon={getHideProp(props.showIcon)}
data-link-variant={props.linkVariant}>
<Slot name="image" />
<Show when={props.headline}>
Expand All @@ -45,7 +45,7 @@ export default function DBNotification(props: DBNotificationProps) {

<Slot name="link" />

<Show when={props.behaviour !== 'permanent'}>
<Show when={props.closeable}>
<DBButton
id={props.closeButtonId}
icon="cross"
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/components/radio/radio.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useTarget
} from '@builder.io/mitosis';
import { DBRadioProps, DBRadioState } from './model';
import { cls, uuid } from '../../utils';
import { cls, getHideProp, uuid } from '../../utils';
import { ChangeEvent, InteractionEvent } from '../../shared/model';
import { handleFrameworkEvent } from '../../utils/form-components';

Expand Down Expand Up @@ -76,12 +76,12 @@ export default function DBRadio(props: DBRadioProps) {
return (
<label
data-size={props.size}
data-variant={props.variant}
data-hide-label={getHideProp(props.showLabel)}
class={cls('db-radio', props.className)}
htmlFor={state._id}>
<input
aria-invalid={props.customValidity === 'invalid'}
data-custom-validity={props.customValidity}
aria-invalid={props.validation === 'invalid'}
data-custom-validity={props.validation}
ref={ref}
type="radio"
id={state._id}
Expand Down
20 changes: 14 additions & 6 deletions packages/components/src/components/select/select.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import {
useTarget
} from '@builder.io/mitosis';
import { DBSelectOptionType, DBSelectProps, DBSelectState } from './model';
import { cls, delay, getHideIcon, hasVoiceOver, uuid } from '../../utils';
import {
cls,
delay,
getBooleanAsString,
getHideProp,
hasVoiceOver,
uuid
} from '../../utils';
import {
DEFAULT_INVALID_MESSAGE,
DEFAULT_INVALID_MESSAGE_ID_SUFFIX,
Expand Down Expand Up @@ -80,7 +87,7 @@ export default function DBSelect(props: DBSelectProps) {
});

/* For a11y reasons we need to map the correct message with the select */
if (!ref?.validity.valid || props.customValidity === 'invalid') {
if (!ref?.validity.valid || props.validation === 'invalid') {
state._descByIds = state._invalidMessageId;
if (hasVoiceOver()) {
state._voiceOverFallback =
Expand All @@ -90,7 +97,7 @@ export default function DBSelect(props: DBSelectProps) {
delay(() => (state._voiceOverFallback = ''), 1000);
}
} else if (
props.customValidity === 'valid' ||
props.validation === 'valid' ||
(ref?.validity.valid && props.required)
) {
state._descByIds = state._validMessageId;
Expand Down Expand Up @@ -166,12 +173,13 @@ export default function DBSelect(props: DBSelectProps) {
<div
class={cls('db-select', props.className)}
data-variant={props.variant}
data-hide-label={getHideProp(props.showLabel)}
data-icon={props.icon}
data-hide-icon={getHideIcon(props.showIcon)}>
data-hide-icon={getHideProp(props.showIcon)}>
<label htmlFor={state._id}>{props.label ?? DEFAULT_LABEL}</label>
<select
aria-invalid={props.customValidity === 'invalid'}
data-custom-validity={props.customValidity}
aria-invalid={props.validation === 'invalid'}
data-custom-validity={props.validation}
ref={ref}
required={props.required}
disabled={props.disabled}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $has-before-padding: calc(
color: colors.$db-adaptive-on-bg-basic-emphasis-100-default;
}

&[data-variant="hidden"] {
&[data-hide-label="true"] {
--db-label-visible-height: 0;
--db-label-visible-spacing: 1;
}
Expand Down
Loading
Loading