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

Move autocomplete styles to PVC #1609

Merged
merged 5 commits into from
Nov 18, 2022
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
5 changes: 5 additions & 0 deletions .changeset/sweet-windows-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Move `autocomplete` styles to PVC
118 changes: 118 additions & 0 deletions app/components/primer/alpha/auto_complete.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/* autocomplete */

/* This file can be deprecated when AutoComplete is upstreamed to PVC + rolled out to dotcom https://github.com/github/primer/issues/796
** AutoComplete relies on FormControl, Overlay and ActionList CSS */

/* Stacked label (default) */
.autocomplete-label-stacked {
display: block;
margin-bottom: 6px;
}

/* Inline label (non-default) */
.autocomplete-label-inline {
display: inline;
margin-right: 6px;
}

/* Switch to stacked at smaller viewport */
@media (max-width: 543.98px) {
.autocomplete-label-inline {
display: block;
margin-bottom: 6px;
}
}

/* Wrapper for the input and result elements to ensure alignment */
.autocomplete-body {
position: relative;
display: inline;
}

/* Wrapper and conditional styles for when an icon is added */
.autocomplete-embedded-icon-wrap {
display: inline-flex;
padding: 4px 8px;
align-items: center;

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

@mixin focusBoxShadowInset;
}

& .form-control {
padding: 0;
margin-left: 8px;
border: none;
box-shadow: none;

&:focus {
box-shadow: none;
}

&:focus-visible {
box-shadow: none;
}
}
}

/* A pop up list of items used to show autocompleted results */
.autocomplete-results {
position: absolute;
left: 0;
z-index: 99;
width: max-content;
min-width: 100%;
max-height: 20em;
overflow-y: auto;
font-size: 13px;
list-style: none;
background: var(--color-canvas-overlay);
border: var(--primer-borderWidth-thin, 1px) solid var(--color-border-default);
border-radius: var(--primer-borderRadius-medium, 6px);
box-shadow: var(--color-shadow-medium);
}

/* One of the items that appears within an autocomplete group
** Bold black text on white background */

.autocomplete-item {
display: block;
width: 100%;
padding: 4px 8px;
overflow: hidden;
font-weight: var(--base-text-weight-semibold, 600);
color: var(--color-fg-default);
text-align: left;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
background-color: var(--color-canvas-overlay);
border: 0;

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

/* Inherit color on all child elements to ensure enough contrast */
& * {
color: inherit !important;
}
}

&.selected,
&[aria-selected='true'],
&.navigation-focus {
color: var(--color-fg-on-emphasis);
text-decoration: none;
background-color: var(--color-accent-emphasis);

/* Inherit color on all child elements to ensure enough contrast */
& * {
color: inherit !important;
}
}
}
1 change: 1 addition & 0 deletions app/components/primer/primer.pcss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* CSS component styles here */
@import "./alpha/action_list.pcss";
@import "./alpha/auto_complete.pcss";
@import "./alpha/banner.pcss";
@import "./alpha/toggle_switch.pcss";
@import "./alpha/segmented_control.pcss";
Expand Down
1 change: 0 additions & 1 deletion demo/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*= require @primer/css/dist/tooltips.css
*= require @primer/css/dist/overlay.css
*= require @primer/css/dist/utilities.css
*= require @primer/css/dist/autocomplete.css
*= require @primer/css/dist/branch-name.css
*= require @primer/css/dist/header.css
*= require @primer/css/dist/loaders.css
Expand Down
3 changes: 3 additions & 0 deletions test/css/component_specific_selectors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class ComponentSpecificSelectorsTest < Minitest::Test
".ActionListItem--subItem>.ActionListContent>.ActionListItem-label",
".ActionList-sectionDivider--filled"
],
Primer::Alpha::AutoComplete => [
".autocomplete-item"
],
Primer::Alpha::Banner => [
".Banner .Banner-close"
],
Expand Down