Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table layout utilities classes also apply to descendant elements; add table layout example docs #5070

Merged
merged 10 commits into from
May 7, 2024

Conversation

jmuzina
Copy link
Member

@jmuzina jmuzina commented Apr 30, 2024

Done

  • Updated the u-table-layout--auto and u-table-layout--fixed utility classes to apply to nested / descended table elements as well as elements with those classes directly applied.
  • Added example docs for the table layout utility settings. This includes:
    • Default (fixed) table layout ($table-layout-fixed: true and no utility class applied directly to a table)
    • Automatic table layout ($table-layout-fixed: true and u-table-layout--auto applied directly to a table)
    • Automatic table layout, nested ($table-layout-fixed: true and u-table-layout--auto applied to an ancestor element of a table

Fixes #2374 , WD-10925

QA

  • Open demo
  • Verify that the example tables in the table layout docs page appear as they do in the attached screenshots.
    • Tables in the table layout utility documentation page should have table-layout: auto applied.
  • Review updated documentation:
    • Docs -> Settings -> Table layout

Check if PR is ready for release

If this PR contains Vanilla SCSS code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 🎁, Breaking Change 💣, Bug 🐛, Documentation 📝, Maintenance 🔨.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention:
    • if CSS class names are not changed it can be bugfix relesase (x.x.X)
    • if CSS class names are changed/added/removed it should be minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) should be listed on the what's new page.

Screenshots

image

@jmuzina jmuzina added Maintenance 🔨 Documentation 📝 Documentation changes or updates labels Apr 30, 2024
@jmuzina jmuzina requested a review from bartaz April 30, 2024 19:09
@jmuzina jmuzina self-assigned this Apr 30, 2024
@webteam-app
Copy link

@jmuzina
Copy link
Member Author

jmuzina commented May 2, 2024

@lyubomir-popov Suggested that this change may be scoped a bit too large. Allowing the css to apply to all tables descended from the utility class element, as Bartek suggested in the Jira card, may be a bit too wide-reaching as this would allow, for example, applying the utility class at the <body>, level and making every <table> in the application to use table-layout: auto.

Perhaps we should revise this to only apply to direct child elements, like so:

  @if ($table-layout-fixed) {
    .u-table-layout--auto {
      &,
      & > table {
        table-layout: auto !important;
      }
    }
  } @else {
    .u-table-layout--fixed {
      &,
      & > table {
        table-layout: fixed !important;
      }
    }
  }

Will review this with @bartaz upon his return from vacation.

scss/_utilities_layout.scss Outdated Show resolved Hide resolved
@@ -0,0 +1,4 @@
@import '../vanilla';
Copy link
Member

Choose a reason for hiding this comment

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

We only use standalone styles for base and components. Utitilies are not featured at all on standalone examples page (https://vanillaframework.io/docs/examples/standalone), as they are kind of independent by nature.

So this file, and references to it in example templates can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed file & references to it


- If `$table-layout-fixed` is set to `true` (the default), you can use `u-table-layout--auto` to override it.
- if `$table-layout-fixed` is set to `auto` it adds a utility called `u-table-layout--fixed`.
- `u-table-layout--auto` sets a table and its descendant tables to `table-layout: auto`.
Copy link
Member

Choose a reason for hiding this comment

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

We don't want people to nest tables, so "its descendant tables" may be a bit misleading, so we should say that this utility sets "the table or any descendant tables of the element it's put on" to auto layout.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated documentation language accordingly

Copy link
Member

@bartaz bartaz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@bartaz bartaz merged commit 8d12cb2 into canonical:main May 7, 2024
5 checks passed
@jmuzina jmuzina deleted the table-layout-utilities-children branch May 7, 2024 15:26
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.

Tables probably shouldn't default to fixed width
4 participants