Skip to content
Merged
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
1 change: 1 addition & 0 deletions packages/admin-ui/src/page/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function Header( {
<HStack
style={ { width: 'auto', flexShrink: 0 } }
spacing={ 2 }
className="admin-ui-page__header-actions"
>
{ actions }
</HStack>
Expand Down
16 changes: 8 additions & 8 deletions packages/admin-ui/src/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Page( {
children,
className,
actions,
hasPadding = true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this prop please. I know it's not used today but most screens that are not dataviews will need it (think settings, style book).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, I don't want this to be left to the consumer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not used today but most screens that are not dataviews will need it (think settings, style book).

If #72135 is an accurate preview of those new screens it doesn't seem like they'll want padding, because it would interfere with the bottom border on the tabs going full width.

I don't want this to be left to the consumer.

I'd like to better understand what's the concern here. Is it that third parties won't use the correct padding?

If the goal is to ensure that third party screens match the padding used elsewhere in the UI, then we'd probably be better off making some CSS custom properties available to consumers of the components, like --container-vertical-padding, --container-horizontal-padding. That way any screen can have tabs or whatever and add the padding only where it's needed.

Another possibility if that tabbed interface is going to be a common one: we make the tabs component available for third parties to build their screens and add the padding to the content areas ourselves.

Otherwise, if we really want to keep this behaviour in the Page component, it's better to make the hasPadding prop false by default, because it doesn't seem to be the majority use case, and render the extra wrapper only if hasPadding is true.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #72135 is an accurate preview of those new screens it doesn't seem like they'll want padding, because it would interfere with the bottom border on the tabs going full width.

The padding is not around the tabs, it's about the left and right padding (and bottom) of the content area.

I'd like to better understand what's the concern here. Is it that third parties won't use the correct padding?

My concern is that it's not the role of the consumer to define the padding of the surface, it should be consistent for all pages.

f the goal is to ensure that third party screens match the padding used elsewhere in the UI, then we'd probably be better off making some CSS custom properties available to consumers of the components, like --container-vertical-padding, --container-horizontal-padding. That way any screen can have tabs or whatever and add the padding only where it's needed.

I disagree, our main reusable bits are components, I'd like us to avoid CSS custom properties between different random CSS files as much as possible. These are not strongly tied together and bugs can arise very quickly. There's very little we can do to statically analyze usage...

Otherwise, if we really want to keep this behaviour in the Page component, it's better to make the hasPadding prop false by default, because it doesn't seem to be the majority use case, and render the extra wrapper only if hasPadding is true.

I think this is just incidental of the fact that we started with dataviews page and that these components are meant to span full width. But IMO, there are way more use-case first and third-parties where padding is needed.

hasPadding = false,
}: {
breadcrumbs?: React.ReactNode;
badges?: React.ReactNode;
Expand All @@ -41,13 +41,13 @@ function Page( {
actions={ actions }
/>
) }
<div
className={ clsx( 'admin-ui-page__content', {
'has-padding': hasPadding,
} ) }
>
{ children }
</div>
{ hasPadding ? (
<div className="admin-ui-page__content has-padding">
{ children }
</div>
) : (
children
) }
</NavigableRegion>
);
}
Expand Down
28 changes: 27 additions & 1 deletion packages/admin-ui/src/page/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.admin-ui-page {
display: flex;
height: 100%;
background: $white;
background-color: $white;
color: $gray-800;
position: relative;
z-index: 1;
flex-flow: column;
container: admin-ui-page / inline-size;

@media not (prefers-reduced-motion) {
Expand Down Expand Up @@ -41,3 +45,25 @@
}
}
}

// Show button text labels when preference is enabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very adhoc to me, and has nothing to do with the Page component, What if folks use other UI components in the header. This is introducing an implicit dependency that is very easy to regress.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ideally this should be a prop in the Button component itself (like "autoSwithToText" or something) and showIconLabels should be something in the ThemeProvider maybe. cc @aduth

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to apply universally across the application?

If no, then it seems appropriate as an application-specific component that wires the preference to the specific button rendering, making it clear in the component naming to be choosing this behavior.

If yes, then my first instinct would be to question the choice of a differing experience at a foundational level and still preferring an application-specific component, but perhaps it could be configurable at a "theme" level. I don't know that it would need a specific button prop in that case though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to apply universally across the application?

It is meant to apply in a lot of places (block toolbars), header icons... I think if you ask folks who activate it, they want it for all icon buttons. That said, it's often hard to guarantee that they'll all work well automatically and this is probably why we're using more of a "curated" approach.

For me, this is a fundamental piece of the IconButton component and not something that I feel is application specific.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button text labels work via a classname applied to the body when the preference is enabled, and local styles in various parts of the codebase. If you search gutenberg for content: attr(aria-label); you should find all the instances.

I agree the implementation could be better but am led to believe by the discussion in #61763 that adding it at the component level is not so straightforward.

if you ask folks who activate it, they want it for all icon buttons

Yes! I use it because I can't tell most of the icons apart from each other 😅 so it would be very helpful to have everywhere.

They do often break because folks don't remember to test the preference or sometimes even to design with it in mind (possibly not everyone knows it exists).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, thanks for the reference to the issue. I should have expected it'd already been discussed at length 😅 I had seen how the class is applied in a bunch of different places which is what led me to suspect it's not uniformly applied.

With some of the challenges outlined in #71196 (specifically Button's bloated API), revisiting those abstractions might help with the challenges raised in #61763 around baking this into the Button component. For example, if we had a dedicated component for "icon buttons", it may be easier and more appropriate for this behavior to be built-in.

.show-icon-labels {
.admin-ui-page__header-actions {
.components-button.has-icon {
width: auto;
padding: 0 $grid-unit-10;

// Hide the button icons when labels are set to display...
svg {
display: none;
}
// ... and display labels.
&::after {
content: attr(aria-label);
font-size: $helptext-font-size;
}
}

}
}

1 change: 0 additions & 1 deletion packages/edit-site/src/components/page-patterns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ export default function DataviewsPatterns() {
<PatternsActions />
</>
}
hasPadding={ false }
>
<DataViews
key={ categoryId + postType }
Expand Down
1 change: 0 additions & 1 deletion packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ export default function PageTemplates() {
<AddNewTemplate />
</>
}
hasPadding={ false }
>
<DataViews
key={ activeView }
Expand Down
6 changes: 0 additions & 6 deletions packages/edit-site/src/components/post-edit/style.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
.edit-site-post-edit {
padding: $grid-unit-30;

&.is-empty .admin-ui-page__content {
display: flex;
align-items: center;
justify-content: center;
}
}

.dataforms-layouts-panel__field-dropdown {
Expand Down
1 change: 0 additions & 1 deletion packages/edit-site/src/components/post-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ export default function PostList( { postType } ) {
) }
</>
}
hasPadding={ false }
>
<DataViews
key={ activeView }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export default function GlobalStylesUIWrapper() {
}
className="edit-site-styles"
title={ __( 'Styles' ) }
hasPadding={ false }
>
<GlobalStylesUI path={ section } onPathChange={ onChangeSection } />
</Page>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.edit-site-styles .admin-ui-page__content {
.edit-site-styles {
.edit-site-global-styles-screen-root {
box-shadow: none;
& > div > hr {
Expand Down Expand Up @@ -26,24 +26,3 @@
}
}

.show-icon-labels {
.edit-site-styles .admin-ui-page__content {
.edit-site-page-header__actions {
.components-button.has-icon {
width: auto;
padding: 0 $grid-unit-10;

// Hide the button icons when labels are set to display...
svg {
display: none;
}
// ... and display labels.
&::after {
content: attr(aria-label);
font-size: $helptext-font-size;
}
}

}
}
}
Loading