Repository navigation
Expand file tree
/
Copy pathmessage.css
More file actions
127 lines (117 loc) · 3.12 KB
/
Copy pathmessage.css
File metadata and controls
127 lines (117 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@import url("https://fonts.googleapis.com/css?family=Noto+Sans+JP:400,500&display=swap");
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
min-height: 100vh;
background: hsl(0, 0%, 100%);
font-family: "Noto Sans JP", sans-serif;
}
/* display the wrapping container in the top right corner of the viewport */
.notification {
position: fixed;
top: 2.2rem;
right: 1rem;
/* align the content to the rigth */
display: flex;
flex-direction: column;
align-items: flex-end;
color: hsl(0, 0%, 20%);
/* hide the overflow to conceal the message when translated to the right of the container */
overflow-x: hidden;
/* padding to avoid cropping the box-shadow on the message */
padding: 0.25rem;
z-index: 1;
pointer-events: none;
}
/* ! for both elements the rotation occurs using the parent group element as a hinge, allowing for the pendulum-like swing */
@keyframes swingBody {
25% {
transform: rotate(-5deg);
}
75% {
transform: rotate(5deg);
}
}
/* animation for the clapper, following the main body and with a larger rotation */
@keyframes swingClapper {
5% {
transform: rotate(0deg);
}
30% {
transform: rotate(-8deg);
}
80% {
transform: rotate(8deg);
}
}
/* style the content of the message to show a grid with the dismiss button in the top right corner
|h1 | button |
|p |p |
*/
.notification__message {
display: grid;
grid-gap: 0.2rem;
grid-template-columns: 1fr auto;
padding: 0.5rem 1rem;
margin: 1rem 0;
/* style the div as a rounded rectangle with a border on the left segment */
background: hsl(0, 0%, 100%);
border-radius: 10px;
box-shadow: 0 0 5px hsla(0, 0%, 0%, 0.1), 0 2px 3px hsla(0, 0%, 0%, 0.1);
border-left: 0.5rem solid hsl(0, 0%, 100%);
/* by default hide the element from sight and include a transition for the chosen properties */
transform: translateX(100%);
opacity: 0;
visibility: hidden;
transition-property: transform, opacity, visibility;
transition-duration: 0.7s;
transition-timing-function: cubic-bezier(0.445, 0.05, 0.55, 0.95);
}
.notification__message h1 {
font-size: 1.1rem;
font-weight: 500;
text-transform: capitalize;
margin-bottom: 4px;
margin-top: 5px;
}
.notification__message p {
max-width: 320px;
min-width: 250px;
font-size: 1.0rem;
grid-column: 1/-1;
margin-bottom: 10px;
}
.notification__message button {
background: none;
border: none;
color: inherit;
width: 20px;
height: 20px;
grid-column: 2/3;
grid-row: 1/2;
align-self: center;
pointer-events: painted;
}
.notification__message button svg {
display: block;
width: 100%;
height: 100%;
}
/* when the .notification container has a class of .received transition the message into view */
.notification.received .notification__message {
transform: translateX(0%);
opacity: 1;
visibility: visible;
}
/* change the border color according to the different modifiers
! for each modifier specify also an svg icon in the background, to highlight the message
*/
.message--success {
border-left-color: hsl(120, 67%, 74%);
background-repeat: no-repeat;
background-size: 35px;
background-position: 100% 100%;
}