Skip to content

Commit

Permalink
feat(Modal): remove deprecated trigger_ props (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
langz authored and tujoworker committed Feb 1, 2023
1 parent 362e574 commit 0784faf
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 258 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,22 +109,10 @@ 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,8 +157,6 @@ exports[`Dialog component snapshot should match component snapshot 1`] = `
}
}
onClick={[Function]}
size={null}
text={null}
title="dialog_title"
variant="secondary"
>
Expand All @@ -192,7 +169,7 @@ 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}
Expand Down Expand Up @@ -281,7 +258,7 @@ 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}
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,22 +107,10 @@ 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,8 +155,6 @@ exports[`Drawer component snapshot should match component snapshot 1`] = `
}
}
onClick={[Function]}
size={null}
text={null}
title="drawer_title"
variant="secondary"
>
Expand All @@ -190,7 +167,7 @@ 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}
Expand Down Expand Up @@ -279,7 +256,7 @@ 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}
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
33 changes: 4 additions & 29 deletions packages/dnb-eufemia/src/components/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,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 @@ -428,18 +418,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,17 +433,12 @@ 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,
hidden: false,
variant: 'secondary',
icon_position: 'left',
...trigger_attributes,
} as ButtonProps

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

0 comments on commit 0784faf

Please sign in to comment.