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
8 changes: 5 additions & 3 deletions src/core/bottom-bar/bottom-bar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ const meta = {
<div
ref={ref}
style={{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: ensuring the storybook docs demo container query behaviour

overflow: 'auto',
height: '300px',
width: '100%',
boxSizing: 'border-box',
border: '1px solid #FA00FF',
containerType: 'inline-size',
height: '300px',
marginInline: 'auto',
overflow: 'auto',
width: '600px',
}}
>
<Pattern height="100vh" />
Expand Down
3 changes: 1 addition & 2 deletions src/core/bottom-bar/item/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ export const ElBottomBarItemIcon = styled.span`
position: relative;

color: var(--comp-navigation-colour-icon-bottom_bar-default);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: small scout. Having the font-size defined outside the ElDeprecatedIcon was dropping the baseline of the element, which was impacting the position of the non-deprecated icons.

font-size: var(--icon_size-l);
width: var(--icon_size-l);
height: var(--icon_size-l);

${ElDeprecatedIcon} {
color: inherit;
font-size: inherit;
font-size: var(--icon_size-l);
width: inherit;
height: inherit;
}
Expand Down
24 changes: 14 additions & 10 deletions src/core/bottom-bar/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isTablet } from '#src/styles/deprecated-media'
import { isWidthAtOrAbove, isWidthBelow } from '#src/utils/breakpoints'
import { styled } from '@linaria/react'

export const ElBottomBarContainer = styled.div`
Expand All @@ -10,16 +10,20 @@ export const ElBottomBarContainer = styled.div`
container-type: inline-size;

display: block;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: because the bottom bar currently relies on an ancestral container that may or may not be present in the DOM, we keep the media queries as a backup.

@supports not (container-type: inline-size) {
${isTablet} {
display: none;
}

@media screen and ${isWidthAtOrAbove('SM')} {
display: none;
}

@container ${isWidthAtOrAbove('SM')} {
display: none;
}
@supports (container-type: inline-size) {
/* NOTE: This is equivalent to the SM breakpoint */
@container (width >= 768px) {
display: none;
}

/* NOTE: This container query will override the default media query behaviour above if there's
* an ancestor is a container. If there's no ancestral container, the media query will behave
* as defined above. */
@container ${isWidthBelow('SM')} {
display: block;
}
`

Expand Down
11 changes: 6 additions & 5 deletions src/core/breadcrumbs/breadcrumbs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export const Example: Story = {
}

/**
* Overflowing should be avoided as much as possible. On SM screen sizes and larger, or when `overflow="truncate"` is
* specified, each item's text will shrink as space becomes limited, using ellipses to indicate truncation has
* occurred, but the breadcrumb separators should remain fully visible. In general, it's best to avoid this situation
* altogether by limiting the number of breadcrumbs in the trail.
* Overflowing should be avoided as much as possible. On SM viewport or container sizes and larger, or
* when `overflow="truncate"` is specified, each item's text will shrink as space becomes limited, using
* ellipses to indicate truncation has occurred, but the breadcrumb separators should remain fully
* visible. In general, it's best to avoid this situation altogether by limiting the number of
* breadcrumbs in the trail.
*/
export const Overflow: Story = {
args: {
Expand All @@ -78,7 +79,7 @@ export const Overflow: Story = {
}

/**
* On XS screen sizes (e.g. under 768px), or when `overflow="scroll"` is specified, the breadcrumbs will be
* In XS viewport or container sizes, or when `overflow="scroll"` is specified, the breadcrumbs will be
* horizontally scrollable, albeit without any visible scrollbar. When scrolling occurs, the focus outlines will
* be clipped; this is expected and considered acceptable.
*/
Expand Down
12 changes: 7 additions & 5 deletions src/core/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ interface BreadcrumbsProps extends HTMLAttributes<HTMLElement> {
}

/**
* Breadcrumbs are used to indicate to the user their flow in the application and provide a navigation back step to
* previous pages. By default, the breadcrumb trails behaviour changes based on screen size.
* Breadcrumbs are used to indicate to the user their flow in the application and provide
* a navigation back step to previous pages. By default, the breadcrumb trails behaviour changes
* based on screen size.
*
* - On XS screen sizes, the trail will grow to its maximum content width and be horizontally scrollable.
* - On SM screen sizes and larger, the trail will grow to its parent container and truncate the text of each item
* using ellipses.
* - In XS viewport or container sizes, the trail will grow to its maximum content
* width and be horizontally scrollable.
* - In SM-2XL viewport or container sizes, the trail will grow to its parent container
* and truncate the text of each item using ellipses.
*
* This dynamic behaviour can be overridden by specifying the `width` property.
*/
Expand Down
34 changes: 31 additions & 3 deletions src/core/breadcrumbs/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styled } from '@linaria/react'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: a few changes like this throughout the PR. Replacing the deprecated media helpers with the new breakpoint conditions.

import { isMobile } from '#src/styles/deprecated-media'
import { isWidthAtOrAbove, isWidthBelow } from '#src/utils/breakpoints'

interface ElBreadcrumbsProps {
'data-overflow'?: 'scroll' | 'truncate'
Expand All @@ -8,12 +8,27 @@ interface ElBreadcrumbsProps {
export const ElBreadcrumbs = styled.nav<ElBreadcrumbsProps>`
width: 100%;

${isMobile} {
/* NOTE: Media and container queries come before data-overflow attribute styles to allow
* the latter to take precedence */
@media screen and ${isWidthBelow('SM')} {
/* NOTE: This is generally considered bad practice */
scrollbar-width: none;
overflow-x: auto;
}

@container ${isWidthBelow('SM')} {
scrollbar-width: none;
overflow-x: auto;
}

/* NOTE: This container query will override the default media query behaviour above if there's
* an ancestor is a container. If there's no ancestral container, the media query will behave
* as defined above. */
@container ${isWidthAtOrAbove('SM')} {
scrollbar-width: initial;
overflow-x: initial;
}

&[data-overflow='scroll'] {
scrollbar-width: none;
overflow-x: auto;
Expand All @@ -34,10 +49,23 @@ export const ElBreadcrumbsList = styled.ul`

width: 100%;

${isMobile} {
/* NOTE: Media and container queries come before data-overflow attribute styles to allow
* the latter to take precedence */
@media screen and ${isWidthBelow('SM')} {
width: max-content;
}

@container ${isWidthBelow('SM')} {
width: max-content;
}

/* NOTE: This container query will override the default media query behaviour above if there's
* an ancestor is a container. If there's no ancestral container, the media query will behave
* as defined above. */
@container ${isWidthAtOrAbove('SM')} {
width: 100%;
}

[data-overflow='truncate'] > & {
width: 100%;
}
Expand Down
44 changes: 23 additions & 21 deletions src/core/page-header/leading-element/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isTablet } from '#src/styles/deprecated-media'
import { isWidthAtOrAbove, isWidthBelow } from '#src/utils/breakpoints'
import { styled } from '@linaria/react'

interface PageHeaderLeadingElementProps {
Expand All @@ -19,24 +19,25 @@ export const ElPageHeaderLeadingElement = styled.div<PageHeaderLeadingElementPro
height: var(--size-6);
width: var(--size-6);

${isTablet} {
@media screen and ${isWidthAtOrAbove('SM')} {
padding-block-start: var(--spacing-1);
height: var(--size-10);
width: var(--size-10);
}

@supports (container-type: inline-size) {
@container (width < 768px) {
padding-block-start: var(--spacing-2);
height: var(--size-6);
width: var(--size-6);
}
@container ${isWidthAtOrAbove('SM')} {
padding-block-start: var(--spacing-1);
height: var(--size-10);
width: var(--size-10);
}

@container (width >= 768px) {
padding-block-start: var(--spacing-1);
height: var(--size-10);
width: var(--size-10);
}
/* NOTE: This container query will override the default media query behaviour above if there's
* an ancestor is a container. If there's no ancestral container, the media query will behave
* as defined above. */
@container ${isWidthBelow('SM')} {
padding-block-start: var(--spacing-2);
height: var(--size-6);
width: var(--size-6);
}
}

Expand All @@ -47,18 +48,19 @@ export const ElPageHeaderLeadingElement = styled.div<PageHeaderLeadingElementPro
padding-block-start: var(--spacing-1);
width: var(--size-16);

${isTablet} {
@media screen and ${isWidthAtOrAbove('SM')} {
width: var(--size-24);
}

@supports (container-type: inline-size) {
@container (width < 768px) {
width: var(--size-16);
}
@container ${isWidthAtOrAbove('SM')} {
width: var(--size-24);
}

@container (width >= 768px) {
width: var(--size-24);
}
/* NOTE: This container query will override the default media query behaviour above if there's
* an ancestor is a container. If there's no ancestral container, the media query will behave
* as defined above. */
@container ${isWidthBelow('SM')} {
width: var(--size-16);
}
}
`
74 changes: 34 additions & 40 deletions src/core/page-header/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDesktop, isTablet } from '#src/styles/deprecated-media'
import { isWidthAtOrAbove, isWidthBelow } from '#src/utils/breakpoints'
import { styled } from '@linaria/react'

import type { CSSProperties } from 'react'
Expand All @@ -24,34 +24,32 @@ export const ElPageHeader = styled.header<PageHeaderProps>`

/* NOTE: Media queries are use by default, but if the browser supports container queries, they will override the
* media query styles defined here. */
${isTablet} {
@media screen and ${isWidthAtOrAbove('SM')} {
padding-block: var(--spacing-8);
padding-inline: var(--spacing-8);
}

${isDesktop} {
@media screen and ${isWidthAtOrAbove('MD')} {
padding-block: var(--spacing-10);
padding-inline: var(--spacing-10);
}

/* NOTE: These container query styles come _after_ the media query styles, so they will override them (if the browser
* supports container queries). These container query styles are also dependent on a parent element being a size or
* inline-size container. */
@supports (container-type: inline-size) {
@container (width < 768px) {
padding-block: var(--spacing-3);
padding-inline: var(--spacing-5) var(--spacing-3);
}

@container (width >= 768px) {
padding-block: var(--spacing-8);
padding-inline: var(--spacing-8);
}

@container (width >= 1024px) {
padding-block: var(--spacing-8);
padding-inline: var(--spacing-10);
}
@container ${isWidthBelow('SM')} {
padding-block: var(--spacing-3);
padding-inline: var(--spacing-5) var(--spacing-3);
}

@container ${isWidthBelow('MD')} {
padding-block: var(--spacing-8);
padding-inline: var(--spacing-8);
}

@container ${isWidthBelow('MD')} {
padding-block: var(--spacing-8);
padding-inline: var(--spacing-10);
}
`

Expand All @@ -61,21 +59,19 @@ export const ElPageHeaderBreadcrumbsContainer = styled.div`

/* NOTE: Media queries are use by default, but if the browser supports container queries, they will override the
* media query styles defined here. */
${isTablet} {
@media screen and ${isWidthAtOrAbove('SM')} {
padding-block-end: var(--spacing-4);
}

@container ${isWidthAtOrAbove('SM')} {
padding-block-end: var(--spacing-4);
}

/* NOTE: These container query styles come _after_ the media query styles, so they will override them (if the browser
* supports container queries). These container query styles are also dependent on a parent element being a size or
* inline-size container. */
@supports (container-type: inline-size) {
@container (width < 768px) {
padding-block-end: var(--spacing-2);
}

@container (width >= 768px) {
padding-block-end: var(--spacing-4);
}
* supports container queries). These container query styles are also dependent on a parent element being a size or
* inline-size container. */
@container ${isWidthBelow('SM')} {
padding-block-end: var(--spacing-2);
}
`

Expand All @@ -85,21 +81,19 @@ export const ElPageHeaderLeadingElementContainer = styled.div`

/* NOTE: Media queries are use by default, but if the browser supports container queries, they will override the
* media query styles defined here. */
${isTablet} {
@media screen and ${isWidthAtOrAbove('SM')} {
padding-inline-end: var(--spacing-4);
}

@container ${isWidthAtOrAbove('SM')} {
padding-inline-end: var(--spacing-4);
}

/* NOTE: These container query styles come _after_ the media query styles, so they will override them (if the browser
* supports container queries). These container query styles are also dependent on a parent element being a size or
* inline-size container. */
@supports (container-type: inline-size) {
@container (width < 768px) {
padding-inline-end: var(--spacing-3);
}

@container (width >= 768px) {
padding-inline-end: var(--spacing-4);
}
* supports container queries). These container query styles are also dependent on a parent element being a size or
* inline-size container. */
@container ${isWidthBelow('SM')} {
padding-inline-end: var(--spacing-3);
}
`

Expand Down
1 change: 1 addition & 0 deletions src/core/top-bar/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TOP_BAR_CONTAINER_NAME = '--top-bar-container'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: extracted this container name to a constants.ts file like we've done for drawer and folder tabs et al.

Loading