Skip to content

Commit a3464ec

Browse files
committed
Merge branch 'master' into release
2 parents a44926e + 2a40f34 commit a3464ec

Some content is hidden

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

60 files changed

+2806
-322
lines changed

.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ module.exports = {
88
'no-undef': 'off',
99
/* Other Rules */
1010
'no-unused-expressions': 'off',
11+
'no-restricted-syntax': [
12+
'error',
13+
{
14+
selector: `CallExpression[callee.object.name='console'][callee.property.name='error']`,
15+
message: 'Using console.error is not allowed as it is sent to Sentry, please use LogService.error instead'
16+
}
17+
],
1118
'arrow-parens': 'off',
1219
// TODO: remove after migration of legacy lifecycle methods
1320
camelcase: 'off',

demo/src/screens/__tests__/__snapshots__/TextFieldScreen.spec.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,6 +3555,14 @@ exports[`TextField Screen renders screen 1`] = `
35553555
accessible={true}
35563556
collapsable={false}
35573557
focusable={true}
3558+
hitSlop={
3559+
{
3560+
"bottom": 15,
3561+
"left": 0,
3562+
"right": 0,
3563+
"top": 15,
3564+
}
3565+
}
35583566
onClick={[Function]}
35593567
onLayout={[Function]}
35603568
onResponderGrant={[Function]}
@@ -4613,6 +4621,14 @@ exports[`TextField Screen renders screen 1`] = `
46134621
accessible={true}
46144622
collapsable={false}
46154623
focusable={true}
4624+
hitSlop={
4625+
{
4626+
"bottom": 7.5,
4627+
"left": 10,
4628+
"right": 10,
4629+
"top": 7.5,
4630+
}
4631+
}
46164632
onClick={[Function]}
46174633
onLayout={[Function]}
46184634
onResponderGrant={[Function]}

demo/src/screens/componentScreens/CheckboxScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default class CheckboxScreen extends Component {
8989
disabled
9090
value={this.state.value5}
9191
onValueChange={value5 => this.setState({value5})}
92-
style={{marginRight: 10}}
92+
style={{marginRight: 20}}
9393
/>
9494
<Checkbox
9595
disabled

demo/src/screens/componentScreens/RadioButtonScreen.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class RadioButtonScreen extends Component {
6969
Radio Buttons
7070
</Text>
7171

72-
<RadioGroup initialValue={this.state.color || null} onValueChange={value => this.setState({color: value})}>
72+
<RadioGroup gap-s4 initialValue={this.state.color || null} onValueChange={value => this.setState({color: value})}>
7373
<Text marginB-20 text60 $textDefault>
7474
Select a color{'\n'}
7575
(enum with default value)
@@ -82,6 +82,7 @@ export default class RadioButtonScreen extends Component {
8282
</RadioGroup>
8383

8484
<RadioGroup
85+
gap-s4
8586
marginT-30
8687
initialValue={this.state.textSide}
8788
onValueChange={value => this.setState({textSide: value})}
@@ -96,7 +97,7 @@ export default class RadioButtonScreen extends Component {
9697
<Text marginT-10>You chose: {this.state.textSide}</Text>
9798
</RadioGroup>
9899

99-
<RadioGroup marginT-30 initialValue={this.state.value} onValueChange={value => this.setState({value})}>
100+
<RadioGroup gap-s4 marginT-30 initialValue={this.state.value} onValueChange={value => this.setState({value})}>
100101
<Text marginB-20 text60 $textDefault>
101102
Yes or No?
102103
</Text>
@@ -112,6 +113,7 @@ export default class RadioButtonScreen extends Component {
112113
</Text>
113114
<View row centerV marginB-10>
114115
<RadioButton
116+
gap-s4
115117
selected={this.state.individualValue2}
116118
onPress={() => this.setState({individualValue2: !this.state.individualValue2})}
117119
label="Individual Radio Button (with style)"

docuilib/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uilib-docs",
3-
"version": "3.3.5",
3+
"version": "3.7.0",
44
"main": "./src/index.ts",
55
"scripts": {
66
"docusaurus": "docusaurus",
@@ -30,6 +30,7 @@
3030
"clsx": "^1.1.1",
3131
"docusaurus-plugin-sass": "^0.2.1",
3232
"file-loader": "^6.2.0",
33+
"prettier": "2.8.8",
3334
"prism-react-renderer": "^2.1.0",
3435
"react-html-parser": "^2.0.2",
3536
"react-native-web": "^0.19.12",

docuilib/src/assets/icons/code.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
3+
const CodeIcon = (props: React.ComponentProps<'svg'>) => {
4+
return (
5+
<svg {...props} viewBox="0 0 18 18" fill="currentColor" width="18" height="18">
6+
<path d="M10,6.00254473 L11,6.00254473 L8,13 L7,13 L10,6.00254473 Z M6,12 L5.74819324,12 L1.99934428,9.78978657 L2.00158404,9.20893357 L5.74819324,7 L6.00018511,7 L6.00018511,8 L3.50778222,9.5 L6,11 L6,12 Z M11.9995294,12 L11.9995294,11 L14.4917472,9.5 L11.9993443,8 L11.9993443,7 L12.2513362,7 L15.9979454,9.20893357 L16.0001851,9.78978657 L12.2513362,12 L11.9995294,12 Z"/>
7+
</svg>
8+
);
9+
};
10+
11+
export default CodeIcon;

docuilib/src/assets/icons/copy.png

-286 Bytes
Binary file not shown.
-448 Bytes
Binary file not shown.

docuilib/src/assets/icons/copy@2x.png

-554 Bytes
Binary file not shown.

docuilib/src/assets/icons/copy@3x.png

-871 Bytes
Binary file not shown.

docuilib/src/assets/icons/copy@4x.png

-1.22 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.codeBlock {
2+
margin: 0;
3+
text-align: 'left';
4+
height: 100%;
5+
}
6+
7+
.codeBlockContainer {
8+
height: 100%;
9+
}

docuilib/src/components/CodeBlock.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React, {useMemo, ComponentProps} from 'react';
2+
import {default as ThemeCodeBlock, Props} from '@theme/CodeBlock';
3+
import styles from './CodeBlock.module.scss';
4+
import useFormattedCode from '../hooks/useFormattedCode';
5+
6+
type CodeBlockProps = {
7+
snippet: string;
8+
printWidth?: number;
9+
fontSize?: number;
10+
} & Omit<Props, 'children'>;
11+
12+
const CodeBlock: React.FC<CodeBlockProps> = ({
13+
snippet,
14+
language,
15+
printWidth = 35,
16+
fontSize = 14,
17+
showLineNumbers,
18+
...others
19+
}) => {
20+
const {code} = useFormattedCode(snippet, {printWidth});
21+
22+
const containerStyle = useMemo<ComponentProps<'div'>['style']>(() => {
23+
return {
24+
fontSize,
25+
maxWidth: printWidth * fontSize
26+
};
27+
}, [fontSize, printWidth]);
28+
29+
return (
30+
<div style={containerStyle} className={styles.codeBlockContainer}>
31+
<ThemeCodeBlock
32+
className={styles.codeBlock}
33+
language={language ?? 'jsx'}
34+
showLineNumbers={showLineNumbers ?? true}
35+
{...others}
36+
>
37+
{code}
38+
</ThemeCodeBlock>
39+
</div>
40+
);
41+
};
42+
43+
export default CodeBlock;

docuilib/src/components/ComponentPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ export default function ComponentPage({component}) {
6060

6161
const buildTabs = () => {
6262
const tabs = component.docs?.tabs;
63-
63+
const api = component.props;
64+
const tabsArray = api ? [...tabs, devTab] : tabs;
65+
6466
// TODO: align Tabs bottom border with TabItem's selected indication line
6567
if (tabs) {
66-
return <Tabs className="main-tabs">{getTabItems([...tabs, devTab])}</Tabs>;
68+
return <Tabs className="main-tabs">{getTabItems(tabsArray)}</Tabs>;
6769
}
6870
};
6971

docuilib/src/components/MainSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default () => {
4040
</div>
4141

4242
<div className={styles.buttons}>
43-
<Link to={`docs/${docsMainEntry}`}>
43+
<Link to={`docs/${location.hostname === 'localhost' ? 'next/' : ''}${docsMainEntry}`}>
4444
<button className={'button dark'}>View Docs</button>
4545
</Link>
4646

docuilib/src/components/UILivePreview.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
55
import BrowserOnly from '@docusaurus/BrowserOnly';
66
import {View, Colors} from 'react-native-ui-lib/core';
77
import ReactLiveScope from '../theme/ReactLiveScope';
8+
import CodeBlock from '@theme/CodeBlock';
89

910
export const IFRAME_MESSAGE_TYPE = 'LIVE_PREVIEW_CODE_UPDATE_MESSAGE';
1011

11-
export default function UILivePreview({code: codeProp}) {
12+
export default function UILivePreview({code: codeProp, componentName = undefined, liveScopeSupport = false}) {
1213
const [code, setCode] = useState(codeProp);
1314
const [iframeLoaded, setIframeLoaded] = useState(false);
1415
const {siteConfig} = useDocusaurusContext();
1516
const iframeRef = useRef(null);
1617

18+
const supportedComponentNames = Object.keys(ReactLiveScope);
19+
const componentLivePlaygroundSupport =
20+
liveScopeSupport || (componentName && supportedComponentNames.includes(componentName));
21+
1722
useEffect(() => {
1823
if (iframeLoaded) {
1924
sendMessageToIframe(code);
@@ -29,6 +34,10 @@ export default function UILivePreview({code: codeProp}) {
2934
return {overflowY: 'scroll', scrollbarWidth: 'none'};
3035
}, []);
3136

37+
if (!componentLivePlaygroundSupport) {
38+
return <CodeBlock language="jsx">{code}</CodeBlock>;
39+
}
40+
3241
return (
3342
<BrowserOnly>
3443
{() => {

docuilib/src/components/pageComponents/Banner.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export const Banner = ({section, component}) => {
8989
const _title = title || getTitle(type);
9090
const _description = description || getDescription(type);
9191

92+
if (!_description) {
93+
return null;
94+
}
95+
9296
return (
9397
<div
9498
className="row"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.showCodeButton {
2+
position: absolute;
3+
border: 0;
4+
background: none;
5+
color: rgb(56, 153, 236);
6+
cursor: pointer;
7+
display: flex;
8+
align-items: center;
9+
right: 0px;
10+
top: 0px;
11+
}
12+
13+
.componentExample {
14+
display: flex;
15+
justify-content: space-between;
16+
}
17+
18+
.componentItemContainer {
19+
position: relative;
20+
height: 100%;
21+
}
22+
23+
.componentSpotlightStyle {
24+
display: flex;
25+
justify-content: center;
26+
align-items: center;
27+
}
28+
29+
.image {
30+
display: flex;
31+
justify-content: center;
32+
align-items: center;
33+
}

0 commit comments

Comments
 (0)