Skip to content

Conversation

@thisisdano
Copy link
Contributor

Removes $output-all-utilities setting and replaces it with $output-these-utilities. $output-all-utilities is an unusual setting — it overrides any utility-specific settings to output all utilities. $output-these-utilities allows users to to create a uselist of all utility modules they want to include in the project.

Previously, to disable any utility, a developer would have to change the value of its settings object. Since all utilities are output by default, disabling the status of multiple utility modules requires adding multiple settings objects, a dreary and tedious affair that looks something like this:

  $display-settings: (
    output: false,
  ),
  $flex-settings: (
    output: false
  ),
  $flex-direction-settings: (
    output: false
  ),
  $flex-wrap-settings: (
    output: false
  ),
  $float-settings: (
    output: false
  ),
  $font-settings: (
    output: false,
  ),

... ad infinitum

With $output-these-utilities, the default is default — which means "all utilities". To include only specific utilities, devs can pass a uselist of all the desired utilities:

  $output-these-utilities: (
    "add-list-reset",
    "align-items",
    "align-self",
    "border",
    "border-style",
    "border-width",
    "color",
    "display",
    "font",
    "font-weight",
    "order",
    "text-decoration"
    ),

Also

  • A couple other minor changes outlined in the notes

$output-these-utilities is a list of utility keys. "default" includes all utilities. If a list of keys is passed, the utility builder will build only those utilities. Utility keys are the names of individual maps stored as variables in uswds-utilities/src/styles/rules
{
$val-value: false;
// Check to see if the utility is in the output uselist
@if ($output-these-utilities == "default") or list.index($output-these-utilities, $utility-name) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only cycle through utilities on the uselist

Comment on lines +145 to +146
.usa-identifier__required-link,
.usa-identifier__required-link.usa-link {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prevent usa-link from overriding Identifier styles, regardless of where the usa-link styles fall in the cascade

$theme-input-tile-border-color: "base-lighter" !default;
$theme-input-tile-border-color-selected: "primary-lighter" !default;
// Deprecated in 3.0.0
$output-all-utilities: true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deprecate $output-all-utilities setting and remove 2.x deprecated settings

+ "\A"
+ "\A Disable notifications using `$theme-show-notifications: false`"
+ "\A in your general settings file."
+ "\A Disable notifications using `$theme-show-notifications: false`."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove reference to multiple settings files


$add-list-reset: (
list-reset: (
add-list-reset: (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use proper name for this utility object key

Comment on lines +18 to +25
// Generate font rules if the `font` utility is on the uselist
// and its output is set to true
@if (($output-these-utilities == "default" or list.index($output-these-utilities, "font")) and map.get($font-settings, "output") == true) {
@each $face, $stack in $project-font-stacks {
@if $stack {
[class*="#{ns('utility')}font-#{$face}-"] {
font-family: #{$stack}#{$if-important};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only output these font rules if the font utility is on the uselist

@thisisdano thisisdano requested a review from mejiaj April 15, 2022 17:24
@thisisdano thisisdano marked this pull request as ready for review April 15, 2022 17:25
Comment on lines +175 to +179
// Only do this if the the utility is meant to output
@if not($media-key) or
($media-key and map-deep-get($utility, settings, responsive))
{
@if map-deep-get($utility, settings, output) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alllll these other changes are just adding a tab indent...

} // end the value loop
} // end the output conditional
}
} // end the uselist conditional
Copy link
Contributor Author

Choose a reason for hiding this comment

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

....and the tab indent section finally ends


$utilities-use-important: false;
$output-all-utilities: true;
$output-these-utilities: default !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.

Whoops, this has a default flag!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIXED

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

Question on notification, otherwise LGTM.

Pretty nice! I was able to successfully create a list of utility overrides and disable a utility breakpoint and only output those new utilities.

Co-authored-by: James Mejia <james.mejia@gsa.gov>
@thisisdano thisisdano merged commit e8d38df into library--develop Apr 15, 2022
@thisisdano thisisdano deleted the dw-improve-utility-output branch April 15, 2022 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants