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

Use @primer/primitive v8 color CSS vars with fallbacks #2083

Merged
merged 20 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 19 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
5 changes: 5 additions & 0 deletions .changeset/cuddly-hats-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Update colors to use Primitive v8 CSS vars
4 changes: 3 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": ["stylelint-config-standard", "stylelint-config-prettier"],
"plugins": ["@primer/stylelint-config/plugins/no-deprecated-colors"],
"ignoreFiles": ["app/**/*.css", "**/*.js", "**/*.ts"],
"rules": {
"custom-property-pattern": null,
Expand All @@ -14,6 +15,7 @@
{
"ignoreAtRules": ["mixin", "define-mixin"]
}
]
],
"primer/no-deprecated-colors": true
}
}
84 changes: 42 additions & 42 deletions app/components/primer/alpha/action_list.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
width: 100%;
height: 1px;
content: '';
background: var(--color-action-list-item-inline-divider);
background: var(--borderColor-muted);
}

/* if descriptionWrap--inline exists, move pseudo divider to wrapper */
Expand All @@ -40,7 +40,7 @@
width: 100%;
height: var(--borderWidth-thin);
content: '';
background: var(--color-action-list-item-inline-divider);
background: var(--borderColor-muted);
}

/* unset the default label pseudo */
Expand Down Expand Up @@ -75,7 +75,7 @@
.ActionListItem {
position: relative;
list-style: none;
background-color: transparent;
background-color: var(--control-transparent-bgColor-rest);
border-radius: var(--borderRadius-medium);

/* state */
Expand Down Expand Up @@ -113,12 +113,12 @@

@media (hover: hover) {
&:hover {
background-color: var(--color-action-list-item-default-hover-bg);
background-color: var(--control-transparent-bgColor-hover);
}
}

&:active {
background-color: var(--color-action-list-item-default-active-bg);
background-color: var(--control-transparent-bgColor-active);
}
}
}
Expand All @@ -130,25 +130,25 @@
@media (hover: hover) {
&:hover {
cursor: pointer;
background-color: var(--color-action-list-item-default-hover-bg);
background-color: var(--control-transparent-bgColor-hover);

&:not(.ActionListItem--navActive, :focus-visible) {
/* Support for "Windows high contrast mode" */
outline: solid var(--borderWidth-thin) transparent;
outline-offset: calc(-1 * var(--borderWidth-thin));
box-shadow: var(--boxShadow-thin) var(--color-action-list-item-default-active-border);
box-shadow: var(--boxShadow-thin) var(--control-transparent-borderColor-active);
}
}
}

&:active {
background: var(--color-action-list-item-default-active-bg);
background: var(--control-transparent-bgColor-active);

&:not(.ActionListItem--navActive) {
/* Support for "Windows high contrast mode" https:sarahmhigley.com/writing/whcm-quick-tips/ */
outline: solid var(--borderWidth-thin) transparent;
outline-offset: calc(-1 * var(--borderWidth-thin));
box-shadow: var(--boxShadow-thin) var(--color-action-list-item-default-active-border);
box-shadow: var(--boxShadow-thin) var(--control-transparent-borderColor-active);
}

& .ActionListItem-label::before,
Expand All @@ -162,11 +162,11 @@

&[aria-selected='true'] {
font-weight: var(--base-text-weight-normal);
background: var(--color-action-list-item-default-selected-bg);
background: var(--control-transparent-bgColor-selected);

@media (hover: hover) {
&:hover {
background-color: var(--color-action-list-item-default-hover-bg);
background-color: var(--control-transparent-bgColor-hover);
}
}

Expand Down Expand Up @@ -195,11 +195,11 @@
}

&:not(.ActionListItem--danger) {
background: var(--color-action-list-item-default-selected-bg);
background: var(--control-transparent-bgColor-selected);

@media (hover: hover) {
&:hover {
background-color: var(--color-action-list-item-default-hover-bg);
background-color: var(--control-transparent-bgColor-hover);
}
}

Expand All @@ -222,11 +222,11 @@
& .ActionListContent {
& .ActionListItem-label,
& .ActionListItem-description {
color: var(--color-primer-fg-disabled);
color: var(--control-fgColor-disabled);
}

& .ActionListItem-visual {
fill: var(--color-primer-fg-disabled);
fill: var(--control-fgColor-disabled);
}
}

Expand All @@ -243,31 +243,31 @@
/* danger */
&.ActionListItem--danger {
& .ActionListItem-label {
color: var(--color-danger-fg);
color: var(--control-danger-fgColor-rest);
}

& .ActionListItem-visual {
color: var(--color-danger-fg);
color: var(--control-danger-fgColor-rest);
}

@media (hover: hover) {
&:hover {
background: var(--color-action-list-item-danger-hover-bg);
background: var(--control-danger-bgColor-hover);

& .ActionListItem-label,
& .ActionListItem-visual {
color: var(--color-action-list-item-danger-hover-text);
color: var(--control-danger-fgColor-hover);
}
}
}

& .ActionListContent {
&:active {
background: var(--color-action-list-item-danger-active-bg);
background: var(--control-danger-bgColor-active);

& .ActionListItem-label,
& .ActionListItem-visual {
color: var(--color-action-list-item-danger-hover-text);
color: var(--control-danger-fgColor-hover);
}
}
}
Expand All @@ -281,7 +281,7 @@
width: 100%;
padding-block: var(--actionListContent-paddingBlock);
padding-inline: var(--control-medium-paddingInline-condensed);
color: var(--color-fg-default);
color: var(--control-fgColor-rest);
text-align: left;
user-select: none;
background-color: transparent;
Expand Down Expand Up @@ -310,11 +310,11 @@
&[aria-disabled='true'] {
& .ActionListItem-label,
& .ActionListItem-description {
color: var(--color-primer-fg-disabled);
color: var(--control-fgColor-disabled);
}

& .ActionListItem-visual {
fill: var(--color-primer-fg-disabled);
fill: var(--control-fgColor-disabled);
}

@media (hover: hover) {
Expand Down Expand Up @@ -399,7 +399,7 @@

/* show active indicator on parent collapse if child is active */
&.ActionListContent--hasActiveSubItem {
background: var(--color-action-list-item-default-selected-bg);
background: var(--control-transparent-bgColor-selected);

& .ActionListItem-label {
font-weight: var(--base-text-weight-semibold);
Expand Down Expand Up @@ -451,13 +451,13 @@
/* checkbox */
& .ActionListItem-multiSelectIcon {
& .ActionListItem-multiSelectIconRect {
fill: var(--color-accent-fg);
stroke: var(--color-accent-fg);
fill: var(--control-checked-bgColor-rest);
stroke: var(--control-checked-bgColor-rest);
stroke-width: var(--borderWidth-thin, 1px);
}

& .ActionListItem-multiSelectCheckmark {
fill: var(--color-fg-on-emphasis);
fill: var(--fgColor-onEmphasis);
}
}
}
Expand Down Expand Up @@ -494,15 +494,15 @@
/* checkbox */
& .ActionListItem-multiSelectIcon {
& .ActionListItem-multiSelectIconRect {
fill: var(--color-canvas-default);
stroke: var(--color-border-default);
fill: var(--bgColor-default);
stroke: var(--control-borderColor-rest);
stroke-width: var(--borderWidth-thin, 1px);
}
}

& .ActionListItem-multiSelectIconRect {
fill: var(--color-canvas-default);
border: var(--borderWidth-thin, 1px) solid var(--color-border-default);
fill: var(--bgColor-default);
border: var(--borderWidth-thin, 1px) solid var(--control-borderColor-rest);
}
}

Expand Down Expand Up @@ -573,7 +573,7 @@
font-size: var(--text-body-size-small);
font-weight: var(--base-text-weight-normal);
line-height: var(--text-body-lineHeight-small);
color: var(--color-fg-muted);
color: var(--fgColor-muted);
}

/* helper for grid alignment with multi-line content
Expand All @@ -582,9 +582,9 @@
.ActionListItem-action {
display: flex;
min-height: var(--control-medium-lineBoxHeight);
color: var(--color-fg-muted);
color: var(--fgColor-muted);
pointer-events: none;
fill: var(--color-fg-muted);
fill: var(--fgColor-muted);
align-items: center;
}

Expand All @@ -594,7 +594,7 @@
font-size: var(--text-body-size-medium);
font-weight: var(--base-text-weight-normal);
line-height: var(--text-body-lineHeight-medium);
color: var(--color-fg-default);
color: var(--fgColor-default);
grid-area: label;
}

Expand Down Expand Up @@ -651,7 +651,7 @@
font-size: var(--text-body-size-small);
line-height: var(--text-body-lineHeight-small);
font-weight: var(--base-text-weight-semibold);
color: var(--color-fg-muted);
color: var(--fgColor-muted);
flex-direction: column;
}

Expand All @@ -664,24 +664,24 @@
margin-block-end: var(--base-size-8);
margin-inline: calc(-1 * var(--base-size-8));
list-style: none;
background: var(--color-action-list-item-inline-divider);
background: var(--borderColor-muted);
border: 0;
}

& .ActionList-sectionDivider-title {
font-size: var(--text-body-size-small);
font-weight: var(--base-text-weight-semibold);
color: var(--color-fg-muted);
color: var(--fgColor-muted);
}
}

.ActionList-sectionDivider--filled {
margin-block-start: calc(var(--base-size-8) - var(--borderWidth-thin));
margin-block-end: var(--base-size-8);
margin-inline: calc(-1 * var(--base-size-8));
background: var(--color-canvas-subtle);
border-top: solid var(--borderWidth-thin) var(--color-action-list-item-inline-divider);
border-bottom: solid var(--borderWidth-thin) var(--color-action-list-item-inline-divider);
background: var(--bgColor-muted);
border-top: solid var(--borderWidth-thin) var(--borderColor-muted);
border-bottom: solid var(--borderWidth-thin) var(--borderColor-muted);

/* if no children, treat as divider */
&:empty {
Expand Down
20 changes: 10 additions & 10 deletions app/components/primer/alpha/auto_complete.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
align-items: center;

&:focus-within {
border-color: var(--color-accent-fg);
border-color: var(--borderColor-accent-emphasis);

@mixin focusBoxShadowInset;
}
Expand Down Expand Up @@ -68,10 +68,10 @@
overflow-y: auto;
font-size: 13px;
list-style: none;
background: var(--color-canvas-overlay);
border: var(--borderWidth-thin) solid var(--color-border-default);
background: var(--overlay-bgColor);
border: var(--borderWidth-thin) solid var(--borderColor-default);
border-radius: var(--borderRadius-medium);
box-shadow: var(--color-shadow-medium);
box-shadow: var(--shadow-resting-medium);
}

/* One of the items that appears within an autocomplete group
Expand All @@ -83,19 +83,19 @@
padding: 4px 8px;
overflow: hidden;
font-weight: var(--base-text-weight-semibold);
color: var(--color-fg-default);
color: var(--fgColor-default);
text-align: left;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
background-color: var(--color-canvas-overlay);
background-color: var(--overlay-bgColor);
border: 0;

&:hover {
color: var(--color-fg-on-emphasis);
color: var(--fgColor-onEmphasis);
text-decoration: none;
background-color: var(--color-accent-emphasis);
background-color: var(--bgColor-accent-emphasis);

/* Inherit color on all child elements to ensure enough contrast */
& * {
Expand All @@ -106,9 +106,9 @@
&.selected,
&[aria-selected='true'],
&.navigation-focus {
color: var(--color-fg-on-emphasis);
color: var(--fgColor-onEmphasis);
text-decoration: none;
background-color: var(--color-accent-emphasis);
background-color: var(--bgColor-accent-emphasis);

/* Inherit color on all child elements to ensure enough contrast */
& * {
Expand Down
Loading