Skip to content

Commit 2b5308e

Browse files
authored
feat(fuselage): Message Template (#458)
1 parent 5fbde6d commit 2b5308e

File tree

52 files changed

+1217
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1217
-102
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

packages/fuselage/fuselage

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Rocket.Chat.Fuselage/packages/fuselage

packages/fuselage/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
if (process.env.NODE_ENV === 'production') {
2-
module.exports = require('./dist/fuselage.production.js');
3-
} else {
4-
module.exports = require('./dist/fuselage.development.js');
5-
}
1+
module.exports = require('./dist/fuselage.development.js');
2+
// if (process.env.NODE_ENV === 'production') {
3+
// module.exports = require('./dist/fuselage.production.js');
4+
// } else {
5+
// }
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,7 @@
11
@use 'sass:map';
22
@use '../../styles/typography.scss';
3-
@use '../../styles/variables/buttons.scss';
4-
5-
@mixin -kind-variant($colors) {
6-
color: map.get($colors, color);
7-
border-width: 2px;
8-
border-style: solid;
9-
border-color: map.get($colors, border-color);
10-
border-radius: 2px;
11-
background-color: map.get($colors, background-color);
12-
13-
appearance: none;
14-
15-
@include on-focus-visible {
16-
border-color: map.get($colors, focus-border-color);
17-
background-color: map.get($colors, focus-background-color);
18-
@include use-focus-shadow(map.get($colors, focus-shadow-color));
19-
}
20-
21-
@include on-hover {
22-
border-color: map.get($colors, hover-border-color);
23-
background-color: map.get($colors, hover-background-color);
24-
@include use-no-shadow;
25-
}
26-
27-
@include on-active {
28-
border-color: map.get($colors, active-border-color);
29-
background-color: map.get($colors, active-background-color);
30-
@include use-no-shadow;
31-
}
32-
33-
@include on-disabled {
34-
color: map.get($colors, disabled-color);
35-
border-color: map.get($colors, disabled-border-color);
36-
background-color: map.get($colors, disabled-background-color);
37-
}
38-
}
3+
@use '../../styles/variables/buttons.scss' as colors;
4+
@use '../../styles/primitives/button.scss';
395

406
.rcx-button {
417
@mixin with-rectangular-size($height, $padding-x, $line-height) {
@@ -78,7 +44,7 @@
7844
$line-height: typography.line-height(p1)
7945
);
8046

81-
@include -kind-variant(buttons.$secondary);
47+
@include button.kind-variant(colors.$secondary);
8248

8349
&--small {
8450
@include typography.use-font-scale(c2);
@@ -111,98 +77,98 @@
11177
}
11278

11379
&--info {
114-
@include -kind-variant(buttons.$secondary-info);
80+
@include button.kind-variant(colors.$secondary-info);
11581
}
11682

11783
&--success {
118-
@include -kind-variant(buttons.$secondary-success);
84+
@include button.kind-variant(colors.$secondary-success);
11985
}
12086

12187
&--warning {
122-
@include -kind-variant(buttons.$secondary-warning);
88+
@include button.kind-variant(colors.$secondary-warning);
12389
}
12490

12591
&--danger {
126-
@include -kind-variant(buttons.$secondary-danger);
92+
@include button.kind-variant(colors.$secondary-danger);
12793
}
12894

12995
&--primary {
130-
@include -kind-variant(buttons.$primary);
96+
@include button.kind-variant(colors.$primary);
13197
}
13298

13399
&--primary-info {
134-
@include -kind-variant(buttons.$info);
100+
@include button.kind-variant(colors.$info);
135101
}
136102

137103
&--primary-success {
138-
@include -kind-variant(buttons.$success);
104+
@include button.kind-variant(colors.$success);
139105
}
140106

141107
&--primary-warning {
142-
@include -kind-variant(buttons.$warning);
108+
@include button.kind-variant(colors.$warning);
143109
}
144110

145111
&--primary-danger {
146-
@include -kind-variant(buttons.$danger);
112+
@include button.kind-variant(colors.$danger);
147113
}
148114

149115
&--ghost {
150-
@include -kind-variant(buttons.$ghost);
116+
@include button.kind-variant(colors.$ghost);
151117
}
152118

153119
&--ghost-info {
154-
@include -kind-variant(buttons.$ghost-info);
120+
@include button.kind-variant(colors.$ghost-info);
155121
}
156122

157123
&--ghost-success {
158-
@include -kind-variant(buttons.$ghost-success);
124+
@include button.kind-variant(colors.$ghost-success);
159125
}
160126

161127
&--ghost-warning {
162-
@include -kind-variant(buttons.$ghost-warning);
128+
@include button.kind-variant(colors.$ghost-warning);
163129
}
164130

165131
&--ghost-danger {
166-
@include -kind-variant(buttons.$ghost-danger);
132+
@include button.kind-variant(colors.$ghost-danger);
167133
}
168134

169135
&--nude {
170-
@include -kind-variant(buttons.$nude);
136+
@include button.kind-variant(colors.$nude);
171137
}
172138

173139
&--nude-info {
174-
@include -kind-variant(buttons.$nude-info);
140+
@include button.kind-variant(colors.$nude-info);
175141
}
176142

177143
&--nude-success {
178-
@include -kind-variant(buttons.$nude-success);
144+
@include button.kind-variant(colors.$nude-success);
179145
}
180146

181147
&--nude-warning {
182-
@include -kind-variant(buttons.$nude-warning);
148+
@include button.kind-variant(colors.$nude-warning);
183149
}
184150

185151
&--nude-danger {
186-
@include -kind-variant(buttons.$nude-danger);
152+
@include button.kind-variant(colors.$nude-danger);
187153
}
188154

189155
&--ghostish {
190-
@include -kind-variant(buttons.$ghostish);
156+
@include button.kind-variant(colors.$ghostish);
191157
}
192158

193159
&--ghostish-info {
194-
@include -kind-variant(buttons.$ghostish-info);
160+
@include button.kind-variant(colors.$ghostish-info);
195161
}
196162

197163
&--ghostish-success {
198-
@include -kind-variant(buttons.$ghostish-success);
164+
@include button.kind-variant(colors.$ghostish-success);
199165
}
200166

201167
&--ghostish-warning {
202-
@include -kind-variant(buttons.$ghostish-warning);
168+
@include button.kind-variant(colors.$ghostish-warning);
203169
}
204170

205171
&--ghostish-danger {
206-
@include -kind-variant(buttons.$ghostish-danger);
172+
@include button.kind-variant(colors.$ghostish-danger);
207173
}
208174
}

packages/fuselage/src/components/Divider/index.d.ts

-6
This file was deleted.

packages/fuselage/src/components/Divider/index.js

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React, { ComponentProps, FC } from 'react';
2+
3+
import { Box } from '../Box';
4+
5+
type DividerProps = ComponentProps<typeof Box>;
6+
7+
const Divider: FC<DividerProps> = (props) => (
8+
<Box is='hr' rcx-divider {...props} />
9+
);
10+
export { Divider };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Meta, Canvas, ArgsTable, Story } from '@storybook/addon-docs/blocks';
2+
3+
import { Divider } from '.';
4+
import { Box } from '../..';
5+
6+
<Meta title='Messages/Divider' parameters={{ jest: ['Divider/spec'] }} />
7+
8+
# Divider
9+
10+
<Canvas>
11+
<Story name='Default'>
12+
<Box>
13+
<Divider>Text</Divider>
14+
<Divider unreadLabel={'Unread'}>Text</Divider>
15+
<Divider unreadLabel={'Unread'} />
16+
</Box>
17+
</Story>
18+
</Canvas>
19+
20+
<ArgsTable of={Divider} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, { FC } from 'react';
2+
3+
const Divider: FC<{
4+
unreadLabel?: string;
5+
}> = ({ children, unreadLabel, ...props }) => (
6+
<div
7+
role='separator'
8+
className={
9+
!unreadLabel
10+
? 'rcx-message-divider'
11+
: 'rcx-message-divider rcx-message-divider--unread'
12+
}
13+
{...props}
14+
>
15+
{children && (
16+
<>
17+
<div className='rcx-message-divider__bar' />
18+
<div className='rcx-message-divider__wrapper'>{children}</div>{' '}
19+
</>
20+
)}
21+
<div className='rcx-message-divider__bar'>
22+
{unreadLabel && (
23+
<div className='rcx-message-divider__wrapper--unread'>
24+
{unreadLabel}
25+
</div>
26+
)}
27+
</div>
28+
</div>
29+
);
30+
export { Divider };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
4+
import { Divider } from '../..';
5+
6+
it('renders without crashing', () => {
7+
const div = document.createElement('div');
8+
ReactDOM.render(<Divider />, div);
9+
ReactDOM.unmountComponentAtNode(div);
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
@use '../../../styles/colors.scss';
2+
@use '../../../styles/lengths.scss';
3+
@use '../../../styles/typography.scss';
4+
5+
$message-background-color: theme(
6+
'message-background-color',
7+
colors.foreground(alternative)
8+
);
9+
10+
$message-divider-background-color: theme(
11+
'message-divider-background-color',
12+
colors.neutral(300)
13+
);
14+
$message-divider-color: theme(
15+
'message-divider-color',
16+
colors.foreground(default)
17+
);
18+
19+
$message-divider-color-unread: theme(
20+
'message-divider-color-unread',
21+
colors.danger(500)
22+
);
23+
$message-divider-background-color-unread: theme(
24+
'message-divider-background-color-unread',
25+
colors.danger(300)
26+
);
27+
28+
$message-divider-size: theme('message-divider-size', lengths.border-width(1));
29+
30+
$message-divider-size-neg: theme(
31+
'message-divider-size-neg',
32+
lengths.margin(-1)
33+
);
34+
35+
.rcx-message-divider {
36+
@include typography.use-font-scale(c1);
37+
position: relative;
38+
z-index: 1;
39+
40+
display: flex;
41+
align-items: center;
42+
43+
margin-bottom: $message-divider-size-neg;
44+
margin-inline: lengths.margin(20);
45+
46+
color: $message-divider-color;
47+
48+
&__bar {
49+
display: flex;
50+
justify-content: flex-end;
51+
align-items: center;
52+
flex-grow: 1;
53+
54+
&::after {
55+
flex-grow: 1;
56+
57+
height: $message-divider-size;
58+
59+
content: '';
60+
61+
background: $message-divider-background-color;
62+
}
63+
}
64+
65+
&--unread &__bar {
66+
&::after {
67+
background: $message-divider-background-color-unread;
68+
}
69+
}
70+
71+
// &--unread {
72+
// &:after,
73+
// &:before {
74+
// }
75+
// }
76+
77+
&__wrapper {
78+
margin-block: lengths.margin(8);
79+
padding-inline: lengths.padding(8);
80+
81+
background-color: $message-background-color;
82+
83+
&--unread {
84+
position: fixed;
85+
z-index: 1;
86+
87+
order: 1;
88+
89+
padding-inline-start: lengths.padding(8);
90+
91+
color: $message-divider-color-unread;
92+
background-color: $message-background-color;
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)