Skip to content

Commit

Permalink
feat(Modal): remove deprecated trigger_ props
Browse files Browse the repository at this point in the history
  • Loading branch information
langz committed Jan 13, 2023
1 parent 931de5f commit 389bb3a
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ModalExampleCloseByHandler = () => (
/* jsx */ `
<Modal
title="Auto close"
trigger_text="Click me"
triggerAttributes={{ text: "Click me" }}
align_content="center"
max_width="40rem"
close_modal={close => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const ModalExampleDrawerHeader = () => (
/* jsx */ `
<Modal
mode="drawer"
trigger_text="Open Drawer"
triggerAttributes={{ text: "Open Drawer" }}
>
<Modal.Bar>
<Breadcrumb />
Expand Down Expand Up @@ -94,7 +94,7 @@ export const ModalExampleDrawerBasic = () => (
<Modal
mode="drawer"
title="Drawer Title"
trigger_text="Open Drawer"
triggerAttributes={{ text: "Open Drawer" }}
>
<Modal.Content>
<P top>This is a left aligned Drawer content.</P>
Expand All @@ -111,7 +111,7 @@ export const DrawerWithoutSpacing = () => (
<Modal
mode="drawer"
title="Drawer without spacing"
trigger_text="Open Drawer with no spacing"
triggerAttributes={{ text: "Open Drawer with no spacing" }}
spacing={false}
>
<Modal.Content>
Expand Down Expand Up @@ -164,9 +164,7 @@ export const ModalExampleFullscreen = () => (
<Modal
title={<span className="dnb-sr-only">"Hidden" Modal title</span>}
fullscreen="true"
trigger_variant="tertiary"
trigger_text="Click me"
trigger_icon="bell"
triggerAttributes={{ text: "Click me", icon: "bell", variant: "tertiary" }}
modal_content="This is the modal text. Triggered by a tertiary button."
/>
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ render(<ChangeValue />)
fullscreen={false}
align_content="centered"
hide_close_button
trigger_text="Show"
triggerAttributes={{ text: "Show" }}
prevent_close={false}
>
<ProgressIndicator
Expand Down Expand Up @@ -310,7 +310,7 @@ render(<ChangeValue />)
fullscreen={false}
align_content="centered"
hide_close_button
trigger_text="Show"
triggerAttributes={{ text: "Show" }}
prevent_close={false}
>
<ProgressIndicator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,11 @@ export default class SidebarLayout extends React.PureComponent {
<MediaQuery when={{ min: 0, max: 'medium' }}>
<Space left="large" top="large">
<PortalToolsMenu
trigger_text="Portal Tools"
trigger_icon="chevron_right"
trigger_icon_position="right"
triggerAttributes={{
text: 'Portal Tools',
icon: 'chevron_right',
icon_position: 'right',
}}
tooltipPosition="bottom"
/>
</Space>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@ exports[`Dialog component snapshot should match component snapshot 1`] = `
title="dialog_title"
trigger={null}
trigger_attributes={null}
trigger_class={null}
trigger_disabled={null}
trigger_hidden={false}
trigger_icon={null}
trigger_icon_position="left"
trigger_size={null}
trigger_text={null}
trigger_title={null}
trigger_variant="secondary"
>
<Modal
align_content="left"
Expand Down Expand Up @@ -118,23 +109,9 @@ exports[`Dialog component snapshot should match component snapshot 1`] = `
title="dialog_title"
trigger={null}
trigger_attributes={null}
trigger_class={null}
trigger_disabled={null}
trigger_hidden={false}
trigger_icon={null}
trigger_icon_position="left"
trigger_size={null}
trigger_text={null}
trigger_title={null}
trigger_variant="secondary"
>
<HelpButtonInstance
class={null}
className="dnb-modal__trigger"
disabled={false}
hidden={false}
icon={null}
icon_position="left"
id="dialog_id"
innerRef={
{
Expand Down Expand Up @@ -178,10 +155,7 @@ exports[`Dialog component snapshot should match component snapshot 1`] = `
}
}
onClick={[Function]}
size={null}
text={null}
title="dialog_title"
variant="secondary"
>
<Button
aria-label="dialog_title"
Expand All @@ -192,10 +166,9 @@ exports[`Dialog component snapshot should match component snapshot 1`] = `
custom_content={null}
custom_element={null}
custom_method={null}
disabled={false}
disabled={null}
element={null}
global_status_id={null}
hidden={false}
href={null}
icon="question"
icon_position="left"
Expand Down Expand Up @@ -266,7 +239,6 @@ exports[`Dialog component snapshot should match component snapshot 1`] = `
aria-roledescription="Hjelp-knapp"
className="dnb-button dnb-button--secondary dnb-help-button dnb-modal__trigger dnb-button--icon-position-left dnb-button--has-icon dnb-button--size-medium"
disabled={false}
hidden={false}
id="dialog_id"
onClick={[Function]}
type="button"
Expand All @@ -281,10 +253,9 @@ exports[`Dialog component snapshot should match component snapshot 1`] = `
custom_content={null}
custom_element={null}
custom_method={null}
disabled={false}
disabled={null}
element={null}
global_status_id={null}
hidden={false}
href={null}
icon="question"
icon_position="left"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ exports[`Drawer component snapshot should match component snapshot 1`] = `
title="drawer_title"
trigger={null}
trigger_attributes={null}
trigger_class={null}
trigger_disabled={null}
trigger_hidden={false}
trigger_icon={null}
trigger_icon_position="left"
trigger_size={null}
trigger_text={null}
trigger_title={null}
trigger_variant="secondary"
>
<Modal
align_content="left"
Expand Down Expand Up @@ -116,23 +107,9 @@ exports[`Drawer component snapshot should match component snapshot 1`] = `
title="drawer_title"
trigger={null}
trigger_attributes={null}
trigger_class={null}
trigger_disabled={null}
trigger_hidden={false}
trigger_icon={null}
trigger_icon_position="left"
trigger_size={null}
trigger_text={null}
trigger_title={null}
trigger_variant="secondary"
>
<HelpButtonInstance
class={null}
className="dnb-modal__trigger"
disabled={false}
hidden={false}
icon={null}
icon_position="left"
id="drawer_id"
innerRef={
{
Expand Down Expand Up @@ -176,10 +153,7 @@ exports[`Drawer component snapshot should match component snapshot 1`] = `
}
}
onClick={[Function]}
size={null}
text={null}
title="drawer_title"
variant="secondary"
>
<Button
aria-label="drawer_title"
Expand All @@ -190,10 +164,9 @@ exports[`Drawer component snapshot should match component snapshot 1`] = `
custom_content={null}
custom_element={null}
custom_method={null}
disabled={false}
disabled={null}
element={null}
global_status_id={null}
hidden={false}
href={null}
icon="question"
icon_position="left"
Expand Down Expand Up @@ -264,7 +237,6 @@ exports[`Drawer component snapshot should match component snapshot 1`] = `
aria-roledescription="Hjelp-knapp"
className="dnb-button dnb-button--secondary dnb-help-button dnb-modal__trigger dnb-button--icon-position-left dnb-button--has-icon dnb-button--size-medium"
disabled={false}
hidden={false}
id="drawer_id"
onClick={[Function]}
type="button"
Expand All @@ -279,10 +251,9 @@ exports[`Drawer component snapshot should match component snapshot 1`] = `
custom_content={null}
custom_element={null}
custom_method={null}
disabled={false}
disabled={null}
element={null}
global_status_id={null}
hidden={false}
href={null}
icon="question"
icon_position="left"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const InputWithError = () => {

const ModalExample = () => (
<Modal
trigger_text="Open Modal"
trigger_attributes={{ text: 'Open Modal' }}
title="Modal Title"
// width="80vw"
on_open={() => {
Expand Down
36 changes: 4 additions & 32 deletions packages/dnb-eufemia/src/components/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,8 @@ class Modal extends React.PureComponent<
open_modal: null,
close_modal: null,

// All "trigger_" are deprecated
trigger: null,
trigger_attributes: null,
trigger_hidden: false,
trigger_disabled: null,
trigger_variant: 'secondary',
trigger_text: null,
trigger_title: null,
trigger_size: null,
trigger_icon: null,
trigger_icon_position: 'left',
trigger_class: null,

overlay_class: null,
content_class: null,
Expand Down Expand Up @@ -429,18 +419,8 @@ class Modal extends React.PureComponent<
open_delay, // eslint-disable-line

omit_trigger_button = false,
// All "trigger_" are deprecated
trigger = null,
trigger_attributes = null,
trigger_hidden = 'false',
trigger_disabled = null,
trigger_variant = 'secondary',
trigger_text = null,
trigger_title = null,
trigger_size = null,
trigger_icon,
trigger_icon_position = 'left',
trigger_class = null,

...rest
} = props
Expand All @@ -453,18 +433,10 @@ class Modal extends React.PureComponent<
)

const render = (suffixProps) => {
const triggerAttributes = {
hidden: isTrue(trigger_hidden),
disabled: isTrue(trigger_disabled),
variant: trigger_variant,
text: trigger_text,
title: trigger_title,
size: trigger_size,
icon: trigger_icon,
icon_position: trigger_icon_position,
class: trigger_class,
...trigger_attributes,
} as ButtonProps
const triggerAttributes = (
trigger_attributes ? { ...trigger_attributes } : {}
) as ButtonProps

if (isTrue(disabled)) {
triggerAttributes.disabled = true
}
Expand Down
Loading

0 comments on commit 389bb3a

Please sign in to comment.