Skip to content

Commit efb2d17

Browse files
authored
feat: update fundamental-styles to v0.12.0-rc.18 (#1172)
BREAKING CHANGE: In this change we * Update fundamental-styles to 0.12.0-rc.18 and support the new features and fixes therein. * Removed LayoutGrid component in favor of the new grid system based on Container, Row, and Column components * Remove LayoutPanel.colSpan property; added story for LayoutPanel in the new grid system. * Removed the TreeViewcomponent in favor of the new Tree component. * Shellbar avatar now has a branded border. * Docs/Storybook: * update storybook to v6.0.16 * fix missing storyDescriptions and component descriptions. * Add copy button to easily copy import statements to clipboard.
1 parent 7ae99b4 commit efb2d17

File tree

63 files changed

+11298
-5495
lines changed

Some content is hidden

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

63 files changed

+11298
-5495
lines changed

.size-limit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
name: "Fundamental-React Size",
44
webpack: true,
55
path: "lib/index.js",
6-
limit: "230 KB"
6+
limit: "236 KB"
77
}
88
]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React, { useState, useEffect } from 'react';
2+
import Button from '../../../src/Button/Button';
3+
4+
const CopyButton = ({ copyText }) => {
5+
const [copyState, setCopyState] = useState('Copy');
6+
const inputId = `offscreen-text-for-${copyText}`
7+
const copyImportStatement = (eve) => {
8+
const inputField = document?.getElementById(inputId);
9+
if(inputField) {
10+
inputField?.select();
11+
inputField?.setSelectionRange(0, 99999);
12+
document?.execCommand("copy");
13+
setCopyState('Copied')
14+
15+
}
16+
}
17+
useEffect(() => {
18+
const resetTimer = setTimeout(() => {
19+
setCopyState('Copy')
20+
}, 5000);
21+
return () => clearTimeout(resetTimer);
22+
}, [copyState]);
23+
24+
return (
25+
<>
26+
<Button
27+
className='copy-import-statement-btn'
28+
compact
29+
glyph='copy'
30+
onClick={copyImportStatement}>
31+
{copyState}
32+
</Button>
33+
<input
34+
aria-hidden
35+
className='docs-offscreen'
36+
id={inputId}
37+
readOnly
38+
tabIndex='-1'
39+
type="text"
40+
value={copyText}
41+
/>
42+
</>
43+
);
44+
};
45+
46+
CopyButton.displayName = 'CopyButton';
47+
48+
export default CopyButton;

.storybook/custom/components/Description.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import React from 'react';
33

44
const Description = (props) => {
55
return (
6-
<Markdown options={{ forceBlock: true}}>{props.desc}</Markdown>
6+
<div className='docs-component-description'>
7+
<Markdown options={{ forceBlock: true}}>{props.desc}</Markdown>
8+
</div>
79
)
810
}
911

.storybook/custom/components/DocsPage.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import React, { useContext, useEffect } from 'react';
1111
import {
1212
Title,
1313
Subtitle,
14+
Description as DocsStoryDescription,
1415
Heading,
1516
Props,
1617
DocsStory,
@@ -40,14 +41,44 @@ const DocsPage = () => {
4041
document.querySelectorAll('.toc-link').forEach( x => x.setAttribute('target','_self'));
4142
}, []);
4243

44+
const showImport = () => {
45+
let groups = context.kind.split('/');
46+
const name = groups[1];
47+
return (
48+
<div className='docs-single-import'>
49+
<Import componentName={name} />
50+
</div>
51+
);
52+
}
53+
54+
const showSubImports = () => {
55+
const subComps = context?.parameters?.subcomponents;
56+
const subImports = [];
57+
if(subComps){
58+
const compNames = Object.keys(subComps);
59+
compNames?.forEach((name, index) => {
60+
subImports.push(<Import key={index} componentName={subComps[name]?.displayName}/>)
61+
})
62+
}
63+
return (
64+
<div className='docs-multi-imports'>
65+
{subImports}
66+
</div>
67+
);
68+
};
69+
4370
return (
4471
<>
4572
<Header />
4673
<Title />
4774
<Toc />
4875
<Subtitle />
49-
{context?.parameters?.description && <Description desc={context?.parameters?.description} />}
50-
<Import />
76+
{context?.parameters?.deprecated && <Description desc={context?.parameters?.deprecated} />}
77+
{!context?.parameters?.noImport && showImport()}
78+
{context?.parameters?.displaySubComponentImports && showSubImports()}
79+
<div className='docs-component-description'>
80+
<DocsStoryDescription />
81+
</div>
5182
<Heading>Examples</Heading>
5283
{stories.map((story) => story && <DocsStory
5384
key={story.id}

.storybook/custom/components/Import.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
import { DocsContext } from '@storybook/addon-docs/blocks';
2-
import { googlecode } from 'react-syntax-highlighter/dist/esm/styles/hljs';
1+
import React from 'react';
32
import SyntaxHighlighter from 'react-syntax-highlighter';
4-
import React, { useContext } from 'react';
3+
import { googlecode } from 'react-syntax-highlighter/dist/esm/styles/hljs';
4+
import CopyButton from './CopyButton';
55

6-
const Import = () => {
7-
const context = useContext(DocsContext);
8-
let groups = context.kind.split('/');
6+
const Import = ({ componentName }) => {
7+
const importStatement = `import { ${componentName} } from 'fundamental-react/lib/${componentName}';`
98
return (
10-
<SyntaxHighlighter
11-
customStyle={{ padding: 10, whiteSpace: 'pre-wrap', fontSize: 14 }}
12-
language='javascript'
13-
style={googlecode}>
14-
{`import { ${groups[groups.length - 1]} } from 'fundamental-react/lib/${groups[1]}';`}
15-
</SyntaxHighlighter>)
16-
}
9+
<div className="docs-import-statement">
10+
<SyntaxHighlighter
11+
customStyle={{ padding: 10, whiteSpace: 'pre-wrap', fontSize: 14 }}
12+
language='javascript'
13+
style={googlecode}>
14+
{importStatement}
15+
</SyntaxHighlighter>
16+
<CopyButton copyText={importStatement} />
17+
</div>
18+
);
19+
};
1720

1821
Import.displayName = 'Import';
1922

.storybook/custom/custom.scss

Lines changed: 135 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ body {
22
font-family: '72', 'Open Sans', sans-serif;
33
}
44

5-
/* override storybook max width */
6-
.sbdocs.sbdocs-content {
7-
width: 100%;
8-
max-width: none;
9-
}
10-
115
/* fix bug in storybook@6 where toolbar height is hardcoded - causes scrollbar */
126
a[title='Open canvas in new tab'] {
137
height: 34px;
148
}
159

10+
.sbdocs.sbdocs-content {
11+
max-width: 85%;
12+
}
13+
1614
/* make room for TOCBot */
1715
@media (min-width: 1024px) {
1816
.sbdocs.sbdocs-content {
@@ -311,3 +309,134 @@ blockquote {
311309
border-color: var(--sapNegativeColor, #bb0000);
312310
}
313311
}
312+
313+
.docs-layout-grid {
314+
.col-content {
315+
min-height: 4rem;
316+
text-align: center;
317+
display: flex;
318+
justify-content: center;
319+
align-items: center;
320+
}
321+
322+
.fd-col--10 {
323+
.col-content {
324+
background-color: #3694b5;
325+
color: black;
326+
}
327+
}
328+
329+
.fd-col--9 {
330+
.col-content {
331+
background-color: #3a73a2;
332+
color: black;
333+
}
334+
}
335+
336+
.fd-col--7 {
337+
.col-content {
338+
background-color: #43317c;
339+
color: white;
340+
}
341+
}
342+
343+
.fd-col--6 {
344+
.col-content {
345+
background-color: #471069;
346+
color: white;
347+
}
348+
}
349+
350+
.fd-col--5 {
351+
.col-content {
352+
background-color: #452073;
353+
color: white;
354+
}
355+
}
356+
357+
.fd-col--4 {
358+
.col-content {
359+
background-color: #414186;
360+
color: white;
361+
}
362+
}
363+
364+
.fd-col--3 {
365+
.col-content {
366+
background-color: #3d6299;
367+
color: white;
368+
}
369+
}
370+
.fd-col--1 {
371+
.col-content {
372+
background-color: #34a4bf;
373+
color: black;
374+
}
375+
}
376+
377+
.docs-layout-grid-first,
378+
.fd-col--12 {
379+
.col-content {
380+
background-color: #30c5d2;
381+
color: black;
382+
}
383+
}
384+
385+
.docs-layout-grid-second,
386+
.fd-col--11 {
387+
.col-content {
388+
background-color: #32b5c8;
389+
color: black;
390+
}
391+
}
392+
393+
.docs-layout-grid-third,
394+
.fd-col--8 {
395+
.col-content {
396+
background-color: #3f528f;
397+
color: white;
398+
}
399+
}
400+
401+
.docs-layout-grid-fourth,
402+
.fd-col--2 {
403+
.col-content {
404+
background-color: #3883ac;
405+
color: black;
406+
}
407+
}
408+
}
409+
410+
.docs-import-statement {
411+
display: inline-flex;
412+
}
413+
414+
.copy-import-statement-btn {
415+
margin: 5px !important;
416+
}
417+
418+
.docs-multi-imports,
419+
.docs-single-import {
420+
margin-bottom: 5em;
421+
}
422+
423+
.docs-single-import,
424+
.docs-multi-imports {
425+
display: flex;
426+
flex-direction: column;
427+
428+
pre {
429+
margin: 0;
430+
}
431+
}
432+
433+
.docs-offscreen {
434+
opacity: 0;
435+
position: absolute;
436+
top: -9999px;
437+
left: -9999px;
438+
}
439+
440+
.docs-component-description {
441+
margin-bottom: 80px;
442+
}

0 commit comments

Comments
 (0)