Skip to content

Conversation

@KristinLBradley
Copy link
Contributor

@KristinLBradley KristinLBradley commented Dec 13, 2025

WIP: Need to confirm screen sizes/breakpoints, etc. we want to support (with designer input)


📌 Summary

If merged, this PR adds responsive column width options to the existing @columnWidth arg of the LayoutGrid component.

Preview: https://hds-showcase-git-kristin-hds-5692-grid-responsive-hashicorp.vercel.app/layouts/grid#responsive-column-width

🛠️ Detailed description

  • Updates the existing @columnWidth option to allow responsive column widths to optionally be passed in as an object.

Views supported:

  • "sm" view (mobile devices)
  • "md" view, 768px and above (tablets and small laptops)
  • "lg" view, 1088px and above (large laptops and desktops)
  • "xl" view, 1440px and above (extra large desktops)
  • "xxl" view, 1920px and above (extra, extra large desktops)

Usage examples:

  • Non-responsive columnWidth (3 columns in all views):
    <Hds::Layout::Grid @columnWidth="33.33%" />
  • "md" & above columnWidth overridden in "small view" only:
    <Hds::Layout::Grid @columnWidth={{hash sm="100%" md="33.33%"}} />
  • Different columnWidth for each supported view:
    <Hds::Layout::Grid @columnWidth={{hash sm="100%" md="50%" lg="33.33%" xl="25%" xxl="20%"}} />
  • All views have 2 columns, except "xxl" which has 4 columns
    <Hds::Layout::Grid @columnWidth={{hash sm="50%" xxl="25%"}} />

📸 Screenshots

Extra, extra large (xxl) view:
image

Extra large (xl) view:
image

Large (lg) view:
image

Medium (md) view:
image

Small (sm) view:
image

🔗 External links


👀 Component checklist

💬 Please consider using conventional comments when reviewing this PR.

📋 PCI review checklist
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've worked with GRC to document the impact of any changes to security controls.
    Examples of changes to controls include access controls, encryption, logging, etc.
  • If applicable, I've worked with GRC to ensure compliance due to a significant change to the in-scope PCI environment.
    Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.

@vercel
Copy link

vercel bot commented Dec 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
hds-showcase Ready Ready Preview Dec 18, 2025 1:35am
hds-website Ready Ready Preview Dec 18, 2025 1:35am

Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

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

I did a first pass and added a few comments (mostly in sync with others). Once some of the open questions have been answered, I want to give it another pass, there are a few things that may be possible to simplify (but I am not sure, I need time to test)

'--hds-layout-grid-column-width-md'?: string;
'--hds-layout-grid-column-width-lg'?: string;

'--hds-layout-grid-column-fill-type-sm'?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

[question] since there is already a "default" auto-fill value for --hds-layout-grid-column-fill-type in CSS, why do we need these extra values, that are assigned auto-fill anyway in JavaScript below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored how the grid column-fill-types work and are set. I think how I've changed it now makes more sense (in addition to reducing repetitious code) but there may be further ways to optimize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think part of the previous issue is the way I was originally setting it was kind of backwards to what I now think is the better approach I pushed up. Going to see if I can optimize a bit further next though.

Co-authored-by: Jory Tindall <jory.tindall@hashicorp.com>
Co-authored-by: Cristiano Rastelli <cristiano.rastelli@hashicorp.com>
…exity, update Showcase with additional examples
Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

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

Left a few comments, but I think we're in the right direction.

if (this.args.columnMinWidth) {
inlineStyles['--hds-layout-grid-column-min-width'] =
this.args.columnMinWidth;
inlineStyles['--hds-layout-grid-column-fill-type'] = 'auto-fit';
Copy link
Contributor

Choose a reason for hiding this comment

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

[question] usually we use CSS variables in JS to pass down to the CSS dynamic values set by the consumers; in this case, we already know the two possible values (auto-fit and auto-fill) and the conditions for them, so could we simply use CSS classes assigned in the get classNames() getter below, using this same logic?

export const GAPS: HdsLayoutGridGaps[] = Object.values(HdsLayoutGridGapValues);

type ResponsiveColumnWidths = {
sm?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

[issue?] should this be required, with the current mobile-first approach? otherwise, with this code

<CodeFragmentWithPlaceholderItems
  @columnCount={{5}}
  @columnWidth={{hash lg="33.33%" xl="25%" xxl="20%"}}
/>

this happens:
Image

alternatively we could use somehow the width/min-width arguments, but I suspect it will make the API more complex

see what you find out, what works better


// "sm" view (mobile devices)
.hds-layout-grid--column-width-sm {
grid-template-columns: repeat(
Copy link
Contributor

Choose a reason for hiding this comment

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

see comment above about the fact that, since this is mobile-first, if the sm is not set then there is no intrinsic width for the columns at this size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll experiment with this more. This is part of why I had the concept of a kind of "default" size in the original implementation.


<ShwDivider @level={{2}} />

<ShwTextH4>With responsive column widths</ShwTextH4>
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think we should have these in a "frameless" page so we can test them? the downside would be that we can't take Percy snapshots of them so they would not be covered for visual regression testing

alternatively, we could create a shared code snippet, to be used here but also in a frameless page, and we could put a link to it like I'm doing here: https://hds-showcase-git-project-solar-phase-1-main-fe-1ffc6c-hashicorp.vercel.app/foundations/theming#demo (see the link under the "demo" section)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants