From f330d61ce9bccc00ac65b0f2a65c7e298e214d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz=20Gonz=C3=A1lez?= Date: Thu, 18 Apr 2024 17:04:13 +0100 Subject: [PATCH 1/5] web: Allow influence Popup size By ignoring the PF/Modal's `variant` prop and adding `blockSize` and `inlineSize` to core/Popup. In addition to "auto", they support "small", "medium", and "large" values that are converted into CSS classes to set the component size based on the viewport. The intention is to keep the dialog at a constant size regardless of its content. Developers should decide which size is best for a dialog based on its content and behavior. --- web/src/assets/styles/utilities.scss | 57 ++++++++++++++++++++++++++++ web/src/components/core/Popup.jsx | 19 +++++++--- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/web/src/assets/styles/utilities.scss b/web/src/assets/styles/utilities.scss index f4303c8617..31c96d36fc 100644 --- a/web/src/assets/styles/utilities.scss +++ b/web/src/assets/styles/utilities.scss @@ -155,6 +155,63 @@ --stack-gutter: 0; } +.block-size-auto { + block-size: auto; +} + + +.inline-size-auto { + inline-size: auto; +} + +.block-size-small, +.block-size-medium, +.block-size-large { + block-size: calc(100dvb - var(--space-large)); +} + +.inline-size-small, +.inline-size-medium, +.inline-size-large { + inline-size: calc(100dvi - var(--spacer-large)); +} + +@media (height > 500px) { + .block-size-small { + block-size: 30dvb; + } + + .block-size-medium { + block-size: 60dvb; + } + + .block-size-large { + block-size: 90dvb; + } +} + +@media (width > 500px) { + .inline-size-small, + .inline-size-medium, + .inline-size-large { + min-inline-size: calc(500px - var(--spacer-large)); + } + + .inline-size-small { + inline-size: 30dvi; + } + + .inline-size-medium { + inline-size: 60dvi; + max-inline-size: var(--ui-max-inline-size); + } + + .inline-size-large { + inline-size: 90dvi; + max-inline-size: calc(var(--ui-max-inline-size) * 2); + } +} + .large { /** block-size fallbacks **/ height: 95dvh; diff --git a/web/src/components/core/Popup.jsx b/web/src/components/core/Popup.jsx index 4c60cc01b0..c54af1344d 100644 --- a/web/src/components/core/Popup.jsx +++ b/web/src/components/core/Popup.jsx @@ -187,27 +187,34 @@ const AncillaryAction = ({ children, ...actionsProps }) => ( * * * - * @param {ModalProps} props + * @typedef {object} PopupBaseProps + * @property {"auto" | "small" | "medium" | "large"} [blockSize="auto"] - The block/height size for the dialog. Default is auto. + * @property {"auto" | "small" | "medium" | "large"} [inlineSize="auto"] - The inline/width size for the dialog. Default is auto. + * @typedef {Omit & PopupBaseProps} PopupProps + * + * @param {PopupProps} props */ const Popup = ({ isOpen = false, showClose = false, - variant = "small", + inlineSize = "medium", + blockSize = "auto", + className = "", children, - ...pfModalProps + ...props }) => { const [actions, content] = partition(React.Children.toArray(children), child => child.type === Actions); return ( /** @ts-ignore */ - { content } + {content} ); }; From 8163d5adc34702eb9ce083bfe8d0adeca4d4af9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz=20Gonz=C3=A1lez?= Date: Fri, 19 Apr 2024 08:26:40 +0100 Subject: [PATCH 2/5] web: Adapt popups to use blockSize and inlineSize props Only when needed. --- web/src/components/core/FileViewer.jsx | 3 ++- web/src/components/core/Terminal.jsx | 3 ++- web/src/components/l10n/L10nPage.jsx | 6 +++--- web/src/components/network/IpSettingsForm.jsx | 6 +++++- web/src/components/network/WifiSelector.jsx | 6 +++++- web/src/components/storage/DeviceSelectionDialog.jsx | 3 ++- web/src/components/storage/ProposalActionsDialog.jsx | 10 ++++++---- web/src/components/storage/SpacePolicyDialog.jsx | 3 ++- web/src/components/users/FirstUser.jsx | 12 ++++++++---- web/src/components/users/RootPasswordPopup.jsx | 2 +- 10 files changed, 36 insertions(+), 18 deletions(-) diff --git a/web/src/components/core/FileViewer.jsx b/web/src/components/core/FileViewer.jsx index 97370e1f22..8fa58990aa 100644 --- a/web/src/components/core/FileViewer.jsx +++ b/web/src/components/core/FileViewer.jsx @@ -60,7 +60,8 @@ export default function FileViewer({ file, title, onCloseCallback }) { {state === "loading" && } {(content === null || error) && diff --git a/web/src/components/core/Terminal.jsx b/web/src/components/core/Terminal.jsx index c07e26ad2d..b718b8ce6a 100644 --- a/web/src/components/core/Terminal.jsx +++ b/web/src/components/core/Terminal.jsx @@ -38,8 +38,9 @@ export default function Terminal({ onCloseCallback }) { return (