Skip to content

Commit 3109c43

Browse files
author
Conrad Chan
authored
feat(docuworks): Add icon support for docuworks files (#2860)
1 parent 9db1ee2 commit 3109c43

9 files changed

Lines changed: 194 additions & 167 deletions

File tree

src/components/preview/previewIcons.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import IconFileThreeD from '../../icon/content/FileThreeD32';
2929
import IconFileVector from '../../icon/content/FileVector32';
3030
import IconFileVideo from '../../icon/content/FileVideo32';
3131
import IconFileWord from '../../icon/content/FileWord32';
32+
import IconFileXbd from '../../icon/content/FileXbd32';
33+
import IconFileXdw from '../../icon/content/FileXdw32';
3234
import IconFileZip from '../../icon/content/FileZip32';
3335
import { SVGProps } from '../accessible-svg/AccessibleSVG';
3436

@@ -168,6 +170,8 @@ register(IconFileVideo, '#009AED', [
168170
'wmv',
169171
]);
170172
register(IconFileWord, '#185ABD', ['doc', 'docx']);
173+
register(IconFileXbd, '#00838D', ['xbd']);
174+
register(IconFileXdw, '#00838D', ['xdw']);
171175
register(IconFileZip, vars.bdlGray20, ['tgz', 'zip']);
172176

173177
export const getColor = (extension?: string): Config['color'] => {

src/icon/content/FileXbd32.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable react/jsx-sort-props */
22
import * as React from 'react';
3+
import * as vars from '../../styles/variables';
34
import AccessibleSVG, { SVGProps } from '../../components/accessible-svg/AccessibleSVG';
45

56
/**
@@ -21,14 +22,14 @@ const FileXbd32 = (props: SVGProps) => (
2122
/>
2223
<path
2324
d="M19.286 3.286l5.01 5.009 1.412 1.412a1 1 0 01.203.293H21a2 2 0 01-2-2V3.09a1 1 0 01.286.196z"
24-
fill="#fff"
25+
fill={vars.white}
2526
fillOpacity={0.5}
2627
/>
2728
<path
2829
fillRule="evenodd"
2930
clipRule="evenodd"
3031
d="M14.583 16v5h2.122c.498 0 .913-.137 1.205-.395.294-.259.452-.63.452-1.076v-.007c0-.565-.34-1.026-.84-1.186.372-.18.625-.588.625-1.034v-.007c0-.394-.14-.722-.404-.95-.263-.227-.638-.345-1.09-.345h-2.07zm4.594 0v5h1.872c.697 0 1.255-.228 1.637-.667.38-.438.575-1.071.575-1.861v-.007c0-.767-.197-1.386-.58-1.813-.383-.429-.94-.652-1.632-.652h-1.872zm-2.765.948c.208 0 .358.054.455.14.095.084.15.21.15.38v.007c0 .171-.058.295-.163.38-.108.086-.279.14-.52.14h-.605v-1.047h.683zm.031 1.911c.265 0 .453.058.573.154.117.092.182.232.182.43v.006c0 .205-.064.348-.178.443-.116.098-.297.157-.555.157h-.737v-1.19h.715zm3.879 1.11V17.03h.578c.383 0 .677.132.878.37.203.24.32.602.32 1.08v.007c0 .498-.114.868-.315 1.11-.198.24-.492.37-.883.37h-.578zM9 20.996h1.35l1.033-1.62 1.035 1.62h1.415l-1.656-2.503L13.858 16H12.46l-.996 1.665L10.461 16H9.005l1.62 2.475L9 20.995z"
31-
fill="#fff"
32+
fill={vars.white}
3233
/>
3334
</AccessibleSVG>
3435
);

src/icon/content/FileXdw32.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable react/jsx-sort-props */
22
import * as React from 'react';
3+
import * as vars from '../../styles/variables';
34
import AccessibleSVG, { SVGProps } from '../../components/accessible-svg/AccessibleSVG';
45

56
/**
@@ -21,14 +22,14 @@ const FileXdw32 = (props: SVGProps) => (
2122
/>
2223
<path
2324
d="M19.286 3.286l5.01 5.009 1.412 1.412a1 1 0 01.203.293H21a2 2 0 01-2-2V3.09a1 1 0 01.286.196z"
24-
fill="#fff"
25+
fill={vars.white}
2526
fillOpacity={0.5}
2627
/>
2728
<path
2829
fillRule="evenodd"
2930
clipRule="evenodd"
3031
d="M9.352 21H8l1.627-2.523L8.005 16h1.457l1.004 1.666.997-1.666h1.4l-1.683 2.495L12.837 21H11.42l-1.036-1.62L9.352 21zm3.918 0v-5h2.035c.75 0 1.354.222 1.771.649.417.427.634 1.046.634 1.816v.007c0 .792-.214 1.427-.629 1.864-.416.438-1.021.664-1.776.664H13.27zm6.01 0l-1.356-5h1.283l.717 3.208.838-3.208h1.024l.854 3.21.71-3.21h1.277l-1.358 5h-1.117l-.88-3.057L20.405 21h-1.125zM14.5 17.031v2.938h.64c.433 0 .757-.133.975-.374.218-.243.342-.61.342-1.107v-.006c0-.476-.127-.837-.348-1.078-.22-.239-.545-.373-.969-.373h-.64z"
31-
fill="#fff"
32+
fill={vars.white}
3233
/>
3334
</AccessibleSVG>
3435
);

src/icons/file-icon/FileIcon.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import IconFileThreeD from '../../icon/content/FileThreeD32';
2727
import IconFileVector from '../../icon/content/FileVector32';
2828
import IconFileVideo from '../../icon/content/FileVideo32';
2929
import IconFileWordDocument from '../../icon/content/FileWord32';
30+
import IconFileXbd from '../../icon/content/FileXbd32';
31+
import IconFileXdw from '../../icon/content/FileXdw32';
3032
import IconFileZip from '../../icon/content/FileZip32';
3133

3234
const Components: { [key: string]: (props: SVGProps) => JSX.Element } = {
@@ -56,6 +58,8 @@ const Components: { [key: string]: (props: SVGProps) => JSX.Element } = {
5658
IconFileVector,
5759
IconFileVideo,
5860
IconFileWordDocument,
61+
IconFileXbd,
62+
IconFileXdw,
5963
IconFileZip,
6064
};
6165

@@ -184,6 +188,8 @@ const EXTENSIONS: { [key: string]: { [key: string]: string } } = {
184188
'wmv',
185189
]),
186190
IconFileWordDocument: mirror(['docx', 'doc', 'docm']),
191+
IconFileXbd: mirror(['xbd']),
192+
IconFileXdw: mirror(['xdw']),
187193
IconFileZip: mirror(['rar', 'tgz', 'zip']),
188194
};
189195

src/icons/file-icon/__tests__/FileIcon.test.tsx

Lines changed: 28 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,76 +10,35 @@ describe('icons/file-icon/FileIcon', () => {
1010

1111
expect(wrapper).toMatchSnapshot();
1212
});
13-
[
14-
{
15-
extension: 'doc',
16-
},
17-
{
18-
extension: 'docx',
19-
},
20-
{
21-
extension: 'docm',
22-
},
23-
{
24-
extension: 'gdoc',
25-
},
26-
{
27-
extension: 'gsheet',
28-
},
29-
{
30-
extension: 'gslides',
31-
},
32-
{
33-
extension: 'gslide',
34-
},
35-
{
36-
extension: 'key',
37-
},
38-
{
39-
extension: 'numbers',
40-
},
41-
{
42-
extension: 'pages',
43-
},
44-
{
45-
extension: 'ppt',
46-
},
47-
{
48-
extension: 'pptx',
49-
},
50-
{
51-
extension: 'pptm',
52-
},
53-
{
54-
extension: 'xls',
55-
},
56-
{
57-
extension: 'xlsm',
58-
},
59-
{
60-
extension: 'xlsb',
61-
},
62-
{
63-
extension: 'zip',
64-
},
65-
{
66-
extension: 'heic',
67-
},
68-
{
69-
extension: 'heif',
70-
},
71-
{
72-
extension: 'HEIC',
73-
},
74-
{
75-
extension: 'HEIF',
76-
},
77-
].forEach(({ extension }) => {
78-
test('should render the expected icon when extension is defined', () => {
79-
const wrapper = getWrapper({ extension });
8013

81-
expect(wrapper).toMatchSnapshot();
82-
});
14+
test.each([
15+
'doc',
16+
'docx',
17+
'docm',
18+
'gdoc',
19+
'gsheet',
20+
'gslides',
21+
'gslide',
22+
'key',
23+
'numbers',
24+
'pages',
25+
'ppt',
26+
'pptx',
27+
'pptm',
28+
'xls',
29+
'xlsm',
30+
'xlsb',
31+
'zip',
32+
'heic',
33+
'heif',
34+
'HEIC',
35+
'HEIF',
36+
'xbd',
37+
'xdw',
38+
])(`should render the expected icon when %s is defined`, extension => {
39+
const wrapper = getWrapper({ extension });
40+
41+
expect(wrapper).toMatchSnapshot();
8342
});
8443

8544
test('should render 64 icon when dimension is defined', () => {

src/icons/file-icon/__tests__/__snapshots__/FileIcon.test.tsx.snap

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,148 +14,162 @@ exports[`icons/file-icon/FileIcon should render default 32 icon when no extensio
1414
/>
1515
`;
1616

17-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 1`] = `
17+
exports[`icons/file-icon/FileIcon should render the expected icon when HEIC is defined 1`] = `
18+
<FileImage32
19+
height={32}
20+
width={32}
21+
/>
22+
`;
23+
24+
exports[`icons/file-icon/FileIcon should render the expected icon when HEIF is defined 1`] = `
25+
<FileImage32
26+
height={32}
27+
width={32}
28+
/>
29+
`;
30+
31+
exports[`icons/file-icon/FileIcon should render the expected icon when doc is defined 1`] = `
1832
<FileWord32
1933
height={32}
2034
width={32}
2135
/>
2236
`;
2337

24-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 2`] = `
38+
exports[`icons/file-icon/FileIcon should render the expected icon when docm is defined 1`] = `
2539
<FileWord32
2640
height={32}
2741
width={32}
2842
/>
2943
`;
3044

31-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 3`] = `
45+
exports[`icons/file-icon/FileIcon should render the expected icon when docx is defined 1`] = `
3246
<FileWord32
3347
height={32}
3448
width={32}
3549
/>
3650
`;
3751

38-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 4`] = `
52+
exports[`icons/file-icon/FileIcon should render the expected icon when gdoc is defined 1`] = `
3953
<FileDocs32
4054
height={32}
4155
width={32}
4256
/>
4357
`;
4458

45-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 5`] = `
59+
exports[`icons/file-icon/FileIcon should render the expected icon when gsheet is defined 1`] = `
4660
<FileSheets32
4761
height={32}
4862
width={32}
4963
/>
5064
`;
5165

52-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 6`] = `
66+
exports[`icons/file-icon/FileIcon should render the expected icon when gslide is defined 1`] = `
5367
<FileSlides32
5468
height={32}
5569
width={32}
5670
/>
5771
`;
5872

59-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 7`] = `
73+
exports[`icons/file-icon/FileIcon should render the expected icon when gslides is defined 1`] = `
6074
<FileSlides32
6175
height={32}
6276
width={32}
6377
/>
6478
`;
6579

66-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 8`] = `
67-
<FileKeynote32
80+
exports[`icons/file-icon/FileIcon should render the expected icon when heic is defined 1`] = `
81+
<FileImage32
6882
height={32}
6983
width={32}
7084
/>
7185
`;
7286

73-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 9`] = `
74-
<FileNumbers32
87+
exports[`icons/file-icon/FileIcon should render the expected icon when heif is defined 1`] = `
88+
<FileImage32
7589
height={32}
7690
width={32}
7791
/>
7892
`;
7993

80-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 10`] = `
81-
<FilePages32
94+
exports[`icons/file-icon/FileIcon should render the expected icon when key is defined 1`] = `
95+
<FileKeynote32
8296
height={32}
8397
width={32}
8498
/>
8599
`;
86100

87-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 11`] = `
88-
<FilePowerpoint32
101+
exports[`icons/file-icon/FileIcon should render the expected icon when numbers is defined 1`] = `
102+
<FileNumbers32
89103
height={32}
90104
width={32}
91105
/>
92106
`;
93107

94-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 12`] = `
95-
<FilePowerpoint32
108+
exports[`icons/file-icon/FileIcon should render the expected icon when pages is defined 1`] = `
109+
<FilePages32
96110
height={32}
97111
width={32}
98112
/>
99113
`;
100114

101-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 13`] = `
115+
exports[`icons/file-icon/FileIcon should render the expected icon when ppt is defined 1`] = `
102116
<FilePowerpoint32
103117
height={32}
104118
width={32}
105119
/>
106120
`;
107121

108-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 14`] = `
109-
<FileExcel32
122+
exports[`icons/file-icon/FileIcon should render the expected icon when pptm is defined 1`] = `
123+
<FilePowerpoint32
110124
height={32}
111125
width={32}
112126
/>
113127
`;
114128

115-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 15`] = `
116-
<FileExcel32
129+
exports[`icons/file-icon/FileIcon should render the expected icon when pptx is defined 1`] = `
130+
<FilePowerpoint32
117131
height={32}
118132
width={32}
119133
/>
120134
`;
121135

122-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 16`] = `
123-
<FileExcel32
136+
exports[`icons/file-icon/FileIcon should render the expected icon when xbd is defined 1`] = `
137+
<FileXbd32
124138
height={32}
125139
width={32}
126140
/>
127141
`;
128142

129-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 17`] = `
130-
<FileZip32
143+
exports[`icons/file-icon/FileIcon should render the expected icon when xdw is defined 1`] = `
144+
<FileXdw32
131145
height={32}
132146
width={32}
133147
/>
134148
`;
135149

136-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 18`] = `
137-
<FileImage32
150+
exports[`icons/file-icon/FileIcon should render the expected icon when xls is defined 1`] = `
151+
<FileExcel32
138152
height={32}
139153
width={32}
140154
/>
141155
`;
142156

143-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 19`] = `
144-
<FileImage32
157+
exports[`icons/file-icon/FileIcon should render the expected icon when xlsb is defined 1`] = `
158+
<FileExcel32
145159
height={32}
146160
width={32}
147161
/>
148162
`;
149163

150-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 20`] = `
151-
<FileImage32
164+
exports[`icons/file-icon/FileIcon should render the expected icon when xlsm is defined 1`] = `
165+
<FileExcel32
152166
height={32}
153167
width={32}
154168
/>
155169
`;
156170

157-
exports[`icons/file-icon/FileIcon should render the expected icon when extension is defined 21`] = `
158-
<FileImage32
171+
exports[`icons/file-icon/FileIcon should render the expected icon when zip is defined 1`] = `
172+
<FileZip32
159173
height={32}
160174
width={32}
161175
/>

0 commit comments

Comments
 (0)