Skip to content

Commit

Permalink
WIP: using subgrid for support sections w/o icon but bleed
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Oct 31, 2023
1 parent 62801ff commit 329ff49
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
31 changes: 21 additions & 10 deletions web/src/assets/styles/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@
// section layouts.
section:not([class^="pf-c"]) {
display: grid;
grid-template-columns: min-content 1fr;
grid-template-areas:
"icon title"
".... content";
grid-template-rows:
[header] auto
[body] auto
;
grid-template-columns: [bleed] min-content [content] 1fr;
gap: var(--spacer-small);
}

section:not(:last-child, [class^="pf-c"]) {
margin-block-end: var(--spacer-large);
}

section > svg {
grid-area: icon;
}

section > h2 {
grid-area: title;
display: grid;
grid-area: header;
grid-template-columns: subgrid;
grid-column: bleed / content-end;

span[data-part="icon"] {
min-width: 32px;
grid-column: bleed / content;
}

span[data-part="title"] {
grid-column: content;
}

button {
border: none;
Expand All @@ -42,7 +51,9 @@ section > h2 {
}

section > .content {
grid-area: content;
display: grid;
grid-template-columns: subgrid;
grid-column: content;
}

// Custom selection list
Expand Down
22 changes: 13 additions & 9 deletions web/src/components/core/Section.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ import { ValidationErrors } from "~/components/core";
*
* @return {React.ReactElement}
*/
const SectionIcon = ({ name, size = 32 }) => {
if (!name) return null;
const SectionIcon = ({ keepBleed = false, name, size = 32 }) => {
if (!name && !keepBleed) return null;

return <Icon name={name} size={size} aria-hidden />;
const Wrapper = ({ children }) => <span data-part="icon">{children}</span>;
const TheIcon = () => name && <Icon name={name} size={size} aria-hidden />;

return <Wrapper><TheIcon /></Wrapper>;
};

/**
Expand All @@ -52,7 +55,7 @@ const SectionIcon = ({ name, size = 32 }) => {
*
* @return {JSX.Element}
*/
const SectionTitle = ({ id, text, path, openDialog }) => {
const SectionTitle = ({ id, keepBleed, iconName, iconSize, text, path, openDialog }) => {
let title = <>{text}</>;

if (path && path !== "") {
Expand All @@ -64,7 +67,8 @@ const SectionTitle = ({ id, text, path, openDialog }) => {

return (
<h2 id={id}>
{title}
<SectionIcon keepBleed={keepBleed} name={iconName} size={iconSize} />
<span data-part="title">{title}</span>
</h2>
);
};
Expand Down Expand Up @@ -142,6 +146,7 @@ export default function Section({
loading,
errors,
children,
keepBleed = false,
"aria-label": ariaLabel
}) {
const headerId = `${name || crypto.randomUUID()}-section-header`;
Expand All @@ -153,11 +158,10 @@ export default function Section({
const SectionHeader = () => {
if (!title) return;

const iconName = loading ? "loading" : icon;

return (
<>
<SectionIcon name={loading ? "loading" : icon} />
<SectionTitle id={headerId} text={title} path={path} openDialog={openDialog} />
</>
<SectionTitle id={headerId} keepBleed={keepBleed} iconName={iconName} text={title} path={path} openDialog={openDialog} />
);
};

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/overview/SoftwareSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export default function SoftwareSection({ showErrors }) {
<Section
key="software-section"
// TRANSLATORS: page section
keepBleed
title={_("Software")}
icon="apps"
loading={state.busy}
errors={errors}
path="/software"
Expand Down

0 comments on commit 329ff49

Please sign in to comment.