Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #333 from unisonweb/color-token-aliases
Browse files Browse the repository at this point in the history
Improve button color configs
  • Loading branch information
hojberg authored Apr 19, 2022
2 parents 0afc669 + 7a09dae commit e104138
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 70 deletions.
10 changes: 0 additions & 10 deletions src/UI/Button.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module UI.Button exposing
, medium
, preventDefault
, primary
, primaryMono
, share
, small
, stopPropagation
Expand Down Expand Up @@ -229,7 +228,6 @@ type Type

type Color
= Default
| PrimaryMono
| Primary
| Share
| Danger
Expand All @@ -255,11 +253,6 @@ default =
withColor Default


primaryMono : Button clickMsg -> Button clickMsg
primaryMono =
withColor PrimaryMono


primary : Button clickMsg -> Button clickMsg
primary =
withColor Primary
Expand Down Expand Up @@ -354,9 +347,6 @@ colorToClassName color =
Default ->
"default"

PrimaryMono ->
"primary-mono"

Primary ->
"primary"

Expand Down
4 changes: 2 additions & 2 deletions src/UnisonLocal/PerspectiveLanding.elm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ viewEmptyStateRoot =
]
]
(Button.iconThenLabel Find Icon.search "Find Definition"
|> Button.primaryMono
|> Button.primary
|> Button.medium
)

Expand All @@ -136,7 +136,7 @@ viewEmptyStateNamespace fqn =
(FQN.view fqn)
[ p [] [ text "Browse, search, read docs, open definitions, and explore" ] ]
(Button.iconThenLabel Find Icon.search ("Find Definitions in " ++ fqn_)
|> Button.primaryMono
|> Button.primary
|> Button.medium
)

Expand Down
4 changes: 2 additions & 2 deletions src/UnisonShare/PerspectiveLanding.elm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ viewEmptyStateRoot =
(span [ class "unison-share" ] [ text "Unison ", span [ class "context" ] [ text "Share" ] ])
[ p [] [ text "Explore to discover and share Unison libraries, documentation, types, and terms." ] ]
(Button.iconThenLabel Find Icon.search "Find Definition"
|> Button.primaryMono
|> Button.primary
|> Button.medium
)

Expand All @@ -130,7 +130,7 @@ viewEmptyStateNamespace fqn =
(FQN.view fqn)
[ p [] [ text "Browse, search, read docs, open definitions, and explore" ] ]
(Button.iconThenLabel Find Icon.search ("Find Definitions in " ++ fqn_)
|> Button.primaryMono
|> Button.primary
|> Button.medium
)

Expand Down
20 changes: 17 additions & 3 deletions src/css/themes/unison-light.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
element, interactive, focus-border, focus-outline, divider, caret, backdrop,
scrollbar, scrollbar-track
text-on-action vs action-text
emphasis
--------
none, very-subdued, subdued, emphasized
Expand All @@ -33,9 +35,6 @@
--u-color_scrollbar: var(--color-gray-lighten-30);
--u-color_scrollbar-track: var(--color-transparent);

--u-color_search-highlight_text: var(--color-gray-blue-2);
--u-color_search-highlight_background: var(--color-transparent);

--u-color_text: var(--color-gray-darken-20);
--u-color_text_very-subdued: var(--color-gray-lighten-30);
--u-color_text_subdued: var(--color-gray-lighten-20);
Expand Down Expand Up @@ -63,6 +62,9 @@
--u-color_action_emphasized: var(--color-gray-darken-20);
--u-color_text-on-action-emphasized: var(--color-gray-lighten-60);
--u-color_icon-on-action-emphasized: var(--color-gray-lighten-30);
--u-color_action_emphasized_hovered: var(--color-gray-darken-10);
--u-color_text-on-action-emphasized_hovered: var(--color-gray-lighten-60);
--u-color_icon-on-action-emphasized_hovered: var(--color-gray-lighten-30);
--u-color_container: var(--color-gray-lighten-100);
--u-color_container_hovered: var(--color-gray-lighten-60);
--u-color_container_selected: var(--color-gray-lighten-60);
Expand All @@ -81,11 +83,23 @@
--u-color_element_emphasized_hovered: var(--color-gray-lighten-50);
--u-color_element_emphasized_selected: var(--color-gray-lighten-50);

--u-color_search-highlight_text: var(--color-gray-blue-2);
--u-color_search-highlight_background: var(--color-transparent);

--u-color_critical_text: var(--color-pink-1);
--u-color_critical_text_subdued: var(--color-pink-3);
--u-color_critical_icon: var(--color-pink-3);
--u-color_critical_action: var(--color-pink-1);
--u-color_critical_text-on-action: var(--color-gray-lighten-100);
--u-color_critical_icon-on-action: var(--color-pink-3);
--u-color_critical_action_hovered: var(--color-pink-2);
--u-color_critical_text-on-action_hovered: var(--color-gray-lighten-100);
--u-color_critical_icon-on-action_hovered: var(--color-pink-3);

--u-color_info_container_subdued: var(--color-blue-5);
--u-color_info_text: var(--color-blue-2);

--u-color_positive_text: var(--color-green-2);

/* Syntax */
--color-syntax-plain: var(--u-color_text);
Expand Down
101 changes: 48 additions & 53 deletions src/css/ui/components/button.css
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
.button {
/* @color-todo */
--color-button-default-text: var(--u-color_text-on-action);
--color-button-default-icon: var(--u-color_icon-on-action);
--color-button-default-bg: var(--u-color_action);
--color-button-default-hover-text: var(--u-color_text-on-action_hovered);
--color-button-default-hover-icon: var(--u-color_text-on-action_hovered);
--color-button-default-hover-bg: var(--u-color_action_hovered);

--color-button-primary-mono-text: var(--color-gray-lighten-60);
--color-button-primary-mono-bg: var(--color-gray-darken-20);
--color-button-primary-mono-hover-text: var(--color-gray-lighten-60);
--color-button-primary-mono-hover-bg: var(--color-gray-darken-10);

/* @deprecate */
--color-button-primary-text: var(--color-gray-lighten-60);
--color-button-primary-bg: var(--color-blue-2);
--color-button-primary-hover-text: var(--color-gray-lighten-60);
--color-button-primary-hover-bg: var(--color-blue-1);
--color-button-primary-text: var(--u-color_text-on-action-emphasized);
--color-button-primary-icon: var(--u-color_icon-on-action-emphasized);
--color-button-primary-bg: var(--u-color_action_emphasized);
--color-button-primary-hover-text: var(
-u-color_text-on-action-emphasized_hovered
);
--color-button-primary-hover-icon: var(
-u-color_icon-on-action-emphasized_hovered
);
--color-button-primary-hover-bg: var(--u-color_action_emphasized_hovered);

--color-button-danger-text: var(--u-color_critical_text-on-action);
--color-button-danger-icon: var(--u-color_critical_icon-on-action);
--color-button-danger-bg: var(--u-color_critical_action);
--color-button-danger-hover-text: var(
--u-color_critical_text-on-action_hovered
);
--color-button-danger-hover-icon: var(
--u-color_critical_icon-on-action_hovered
);
--color-button-danger-hover-bg: var(--u-color_critical_action_hovered);

/* @color-todo */
/* @decorative */
--color-button-decorative-blue-text: var(--color-gray-lighten-60);
--color-button-decorative-blue-bg: var(--color-blue-2);
--color-button-decorative-blue-hover-text: var(--color-gray-lighten-60);
--color-button-decorative-blue-hover-bg: var(--color-blue-1);

--color-button-share-text: var(--color-purple-1);
--color-button-share-bg: var(--color-purple-4);
--color-button-share-hover-text: var(--color-purple-2);
--color-button-share-hover-bg: var(--color-purple-4);

--color-button-danger-text: var(--color-gray-lighten-100);
--color-button-danger-bg: var(--color-pink-1);
--color-button-danger-hover-text: var(--color-gray-lighten-100);
--color-button-danger-hover-bg: var(--color-pink-2);

display: inline-flex;
font-family: var(--font-sans-serif);
border: 0;
Expand Down Expand Up @@ -107,7 +118,7 @@ a.button:hover {
background: var(--color-button-default-bg);
}
.button.contained.default .icon {
color: var(--color-button-default-text);
color: var(--color-button-default-icon);
}

.button.contained.default:hover {
Expand All @@ -116,40 +127,40 @@ a.button:hover {
}

.button.contained.default:hover .icon {
color: var(--color-button-default-hover-text);
}

.button.contained.primary-mono {
color: var(--color-button-primary-mono-text);
background: var(--color-button-primary-mono-bg);
}

.button.contained.primary-mono .icon {
color: var(--color-button-primary-mono-text);
}

.button.contained.primary-mono:hover {
color: var(--color-button-primary-mono-hover-text);
background: var(--color-button-primary-mono-hover-bg);
}
.button.contained.primary-mono:hover .icon {
color: var(--color-button-primary-mono-hover-text);
color: var(--color-button-default-hover-icon);
}

.button.contained.primary {
color: var(--color-button-primary-text);
background: var(--color-button-primary-bg);
}
.button.contained.primary .icon {
color: var(--color-button-primary-text);
color: var(--color-button-primary-icon);
}

.button.contained.primary:hover {
color: var(--color-button-primary-hover-text);
background: var(--color-button-primary-hover-bg);
}
.button.contained.primary:hover .icon {
color: var(--color-button-primary-hover-text);
color: var(--color-button-primary-hover-icon);
}

.button.contained.danger {
color: var(--color-button-danger-text);
background: var(--color-button-danger-bg);
}

.button.contained.danger .icon {
color: var(--color-button-danger-icon);
}

.button.contained.danger:hover {
color: var(--color-button-danger-text);
background: var(--color-button-danger-bg);
}
.button.contained.danger:hover .icon {
color: var(--color-button-danger-icon);
}

.button.contained.share {
Expand All @@ -170,22 +181,6 @@ a.button:hover {
color: var(--color-button-share-hover-text);
}

.button.contained.danger {
color: var(--color-button-danger-text);
background: var(--color-button-danger-bg);
}
.button.contained.danger .icon {
color: var(--color-button-danger-text);
}

.button.contained.danger:hover {
color: var(--color-button-danger-text);
background: var(--color-button-danger-bg);
}
.button.contained.danger:hover .icon {
color: var(--color-button-danger-text);
}

/* -- Uncontained & Colors ------------------------------------------------- */
.button.uncontained {
background: var(--color-transparent);
Expand Down

0 comments on commit e104138

Please sign in to comment.