Skip to content

Commit b0afe2e

Browse files
authored
Move Granite specific button styles to Granite Dir (#872)
1 parent e56c931 commit b0afe2e

File tree

4 files changed

+94
-81
lines changed

4 files changed

+94
-81
lines changed

lib/Styles/Common/_controls.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,20 @@
6060
background-color: scale-color($trough-color, $alpha: -10%);
6161
}
6262
}
63+
64+
%raised {
65+
@include control;
66+
@include border-interactive-roundrect;
67+
68+
&:active,
69+
&:checked {
70+
@include control-active;
71+
filter: brightness(95%);
72+
transform: none;
73+
}
74+
75+
&:disabled {
76+
@include control-disabled;
77+
}
78+
79+
}

lib/Styles/Granite/Button.scss

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
button {
2+
3+
.linked &,
4+
.linked &.image-button,
5+
.linked &.image-button.toggle {
6+
@extend %raised;
7+
8+
// I don't know why this needs to be reiterated, but it doesn't work
9+
// properly without it
10+
&:active,
11+
&:checked {
12+
@include control-active;
13+
color: $fg-color;
14+
transform: none;
15+
}
16+
}
17+
18+
&.osd {
19+
@include control;
20+
@include border-interactive-roundrect;
21+
22+
// This stacks with the other shadows,
23+
// so reduce it's alpha by the sum of other shadows
24+
$shadow-border-color: scale-color($border-color, $alpha: -50%);
25+
@if $color-scheme == "dark" {
26+
$shadow-border-color: transparent
27+
}
28+
29+
background-image: none;
30+
border: none;
31+
box-shadow:
32+
highlight(),
33+
// Intentionally not in ems since it's used as a stroke
34+
0 0 0 1px $shadow-border-color,
35+
shadow(2);
36+
color: $fg-color;
37+
margin: 0;
38+
padding: $button-spacing;
39+
40+
transition:
41+
background duration("expand") easing(),
42+
transform duration("expand") easing("ease-out-back");
43+
44+
&:active {
45+
transition:
46+
background duration("collapse") easing(),
47+
transform duration("collapse") easing();
48+
}
49+
50+
&:disabled {
51+
@include control-disabled;
52+
53+
box-shadow:
54+
highlight(),
55+
// Intentionally not in ems since it's used as a stroke
56+
0 0 0 1px $shadow-border-color,
57+
shadow(1);
58+
}
59+
60+
.linked & {
61+
transition: none;
62+
transform: none;
63+
}
64+
65+
.linked &.vertical &:first-child {
66+
box-shadow:
67+
highlight("top"),
68+
// Intentionally not in ems since it's used as a stroke
69+
0 0 0 1px $shadow-border-color,
70+
shadow(2);
71+
}
72+
}
73+
74+
}

lib/Styles/Granite/Index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import '_classes.scss';
22
@import 'Box.scss';
3+
@import 'Button.scss';
34
@import 'Dialog.scss';
45
@import 'Header.scss';
56
@import 'ListItem.scss';

lib/Styles/Gtk/Button.scss

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
button {
22

3-
&.text-button {
4-
padding: rem(2px) rem(4px);
5-
}
6-
73
&.image-button {
84
@extend .circular;
95

@@ -31,87 +27,12 @@ button {
3127
}
3228
}
3329

34-
.linked &,
35-
.linked &.image-button,
36-
.linked &.image-button.toggle,
3730
&.text-button {
38-
@include control;
39-
@include border-interactive-roundrect;
40-
41-
&:active,
42-
&:checked {
43-
@include control-active;
44-
transform: none;
45-
}
46-
47-
&:active {
48-
filter: brightness(95%);
49-
}
31+
@extend %raised;
5032

51-
&:disabled {
52-
@include control-disabled;
53-
}
54-
55-
&:hover {
56-
filter: brightness(105%);
57-
}
33+
padding: rem(2px) rem(4px);
5834
}
5935

60-
&.osd {
61-
@include control;
62-
@include border-interactive-roundrect;
63-
64-
// This stacks with the other shadows,
65-
// so reduce it's alpha by the sum of other shadows
66-
$shadow-border-color: scale-color($border-color, $alpha: -50%);
67-
@if $color-scheme == "dark" {
68-
$shadow-border-color: transparent
69-
}
70-
71-
background-image: none;
72-
border: none;
73-
box-shadow:
74-
highlight(),
75-
// Intentionally not in ems since it's used as a stroke
76-
0 0 0 1px $shadow-border-color,
77-
shadow(2);
78-
color: $fg-color;
79-
margin: 0;
80-
padding: $button-spacing;
81-
82-
transition:
83-
background duration("expand") easing(),
84-
transform duration("expand") easing("ease-out-back");
85-
86-
&:active {
87-
transition:
88-
background duration("collapse") easing(),
89-
transform duration("collapse") easing();
90-
}
91-
92-
&:disabled {
93-
@include control-disabled;
94-
95-
box-shadow:
96-
highlight(),
97-
// Intentionally not in ems since it's used as a stroke
98-
0 0 0 1px $shadow-border-color,
99-
shadow(1);
100-
}
101-
102-
.linked & {
103-
transition: none;
104-
transform: none;
105-
}
106-
107-
.linked &.vertical &:first-child {
108-
box-shadow:
109-
highlight("top"),
110-
// Intentionally not in ems since it's used as a stroke
111-
0 0 0 1px $shadow-border-color,
112-
shadow(2);
113-
}
114-
}
11536

11637
// Almost certainly a button with text and image
11738
> box.horizontal {

0 commit comments

Comments
 (0)