Skip to content

Commit

Permalink
Fixed #32018 -- Extracted admin colors into CSS variables.
Browse files Browse the repository at this point in the history
Defined all colors used in the admin CSS as variables. Implemented the
following standardizations and accessibility improvements while at it:

- Improved the contrast of text to not use ratios of less than 3:1 anymore.
- Most hover states already used desaturated and darkened colors.
  Changed object tools to follow the same rule instead of showing the
  primary color on hover.

Various places used similar colors; those have been merged with the goal
of reducing the count of CSS variables. Contrasts have been improved in
a few places.

- Many borders used slightly different colors (e.g. #eaeaea vs. #eee)
- Help texts used #999, this has been changed to --body-quiet-color
  (#666) which has a better contrast.

Introduced fast color transitions on links and buttons.
  • Loading branch information
matthiask authored and carltongibson committed Jan 7, 2021
1 parent 102d92f commit 8143267
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 230 deletions.
35 changes: 19 additions & 16 deletions django/contrib/admin/static/admin/css/autocomplete.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ select.admin-autocomplete {

.select2-container--admin-autocomplete.select2-container--focus .select2-selection,
.select2-container--admin-autocomplete.select2-container--open .select2-selection {
border-color: #999;
border-color: var(--body-quiet-color);
min-height: 30px;
}

Expand All @@ -29,13 +29,13 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--single {
background-color: #fff;
border: 1px solid #ccc;
background-color: var(--body-bg);
border: 1px solid var(--border-color);
border-radius: 4px;
}

.select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered {
color: #444;
color: var(--body-fg);
line-height: 30px;
}

Expand All @@ -46,7 +46,7 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--single .select2-selection__placeholder {
color: #999;
color: var(--body-quiet-color);
}

.select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow {
Expand Down Expand Up @@ -95,7 +95,7 @@ select.admin-autocomplete {

.select2-container--admin-autocomplete .select2-selection--multiple {
background-color: white;
border: 1px solid #ccc;
border: 1px solid var(--border-color);
border-radius: 4px;
cursor: text;
}
Expand All @@ -115,7 +115,7 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__placeholder {
color: #999;
color: var(--body-quiet-color);
margin-top: 5px;
float: left;
}
Expand All @@ -131,7 +131,7 @@ select.admin-autocomplete {

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice {
background-color: #e4e4e4;
border: 1px solid #ccc;
border: 1px solid var(--border-color);
border-radius: 4px;
cursor: default;
float: left;
Expand All @@ -141,15 +141,15 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice__remove {
color: #999;
color: var(--body-quiet-color);
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-right: 2px;
}

.select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #333;
color: var(--body-fg);
}

.select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--admin-autocomplete[dir="rtl"] .select2-selection--multiple .select2-search--inline {
Expand All @@ -167,7 +167,7 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete.select2-container--focus .select2-selection--multiple {
border: solid #999 1px;
border: solid var(--body-quiet-color) 1px;
outline: 0;
}

Expand All @@ -191,7 +191,7 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-search--dropdown .select2-search__field {
border: 1px solid #ccc;
border: 1px solid var(--border-color);
}

.select2-container--admin-autocomplete .select2-search--inline .select2-search__field {
Expand All @@ -205,18 +205,21 @@ select.admin-autocomplete {
.select2-container--admin-autocomplete .select2-results > .select2-results__options {
max-height: 200px;
overflow-y: auto;
color: var(--body-fg);
background: var(--body-bg);
}

.select2-container--admin-autocomplete .select2-results__option[role=group] {
padding: 0;
}

.select2-container--admin-autocomplete .select2-results__option[aria-disabled=true] {
color: #999;
color: var(--body-quiet-color);
}

.select2-container--admin-autocomplete .select2-results__option[aria-selected=true] {
background-color: #ddd;
background-color: var(--selected-bg);
color: var(--body-fg);
}

.select2-container--admin-autocomplete .select2-results__option .select2-results__option {
Expand Down Expand Up @@ -253,8 +256,8 @@ select.admin-autocomplete {
}

.select2-container--admin-autocomplete .select2-results__option--highlighted[aria-selected] {
background-color: #79aec8;
color: white;
background-color: var(--primary);
color: var(--body-bg);
}

.select2-container--admin-autocomplete .select2-results__group {
Expand Down

0 comments on commit 8143267

Please sign in to comment.