Skip to content

Commit c136ab0

Browse files
committed
Merge branch 'master' into release
2 parents 6d53d3b + 81c2ccc commit c136ab0

34 files changed

+1172
-59
lines changed

demo/src/screens/MenuStructure.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const navigationData = {
3838
{title: 'Page Control', tags: 'page', screen: 'unicorn.components.PageControlScreen'},
3939
{title: 'ProgressBar', tags: 'progress bar animated', screen: 'unicorn.animations.ProgressBarScreen'},
4040
{title: 'ScrollBar', tags: 'scroll bar gradient', screen: 'unicorn.components.ScrollBarScreen'},
41+
{title: 'SearchInputScreen', tags: 'search input', screen: 'unicorn.components.SearchInputScreen'},
4142
{
4243
title: 'Shared Transition',
4344
tags: 'shared transition element',
@@ -99,16 +100,18 @@ export const navigationData = {
99100
{title: 'Conversation List', tags: 'list conversation', screen: 'unicorn.lists.ConversationListScreen'},
100101
{title: 'Drawer', tags: 'drawer', screen: 'unicorn.components.DrawerScreen'},
101102
{title: 'SortableList', tags: 'sortable list drag', screen: 'unicorn.components.SortableListScreen'},
102-
{title: 'HorizontalSortableList', tags: 'sortable horizontal list drag', screen: 'unicorn.components.HorizontalSortableListScreen'},
103+
{
104+
title: 'HorizontalSortableList',
105+
tags: 'sortable horizontal list drag',
106+
screen: 'unicorn.components.HorizontalSortableListScreen'
107+
},
103108
{title: 'GridList', tags: 'grid list', screen: 'unicorn.components.GridListScreen'},
104109
{title: 'SortableGridList', tags: 'sort grid list drag', screen: 'unicorn.components.SortableGridListScreen'}
105110
]
106111
},
107112
Charts: {
108113
title: 'Charts',
109-
screens: [
110-
{title: 'PieChart', tags: 'pie chart data', screen: 'unicorn.components.PieChartScreen'}
111-
]
114+
screens: [{title: 'PieChart', tags: 'pie chart data', screen: 'unicorn.components.PieChartScreen'}]
112115
},
113116
LayoutsAndTemplates: {
114117
title: 'Layouts & Templates',
@@ -120,7 +123,11 @@ export const navigationData = {
120123
{title: 'Modal', tags: 'modal topbar screen', screen: 'unicorn.screens.ModalScreen'},
121124
{title: 'StateScreen', tags: 'empty state screen', screen: 'unicorn.screens.EmptyStateScreen'},
122125
{title: 'TabController', tags: 'tabbar controller native', screen: 'unicorn.components.TabControllerScreen'},
123-
{title: 'TabControllerWithStickyHeader', tags: 'tabbar controller native sticky header', screen: 'unicorn.components.TabControllerWithStickyHeaderScreen'},
126+
{
127+
title: 'TabControllerWithStickyHeader',
128+
tags: 'tabbar controller native sticky header',
129+
screen: 'unicorn.components.TabControllerWithStickyHeaderScreen'
130+
},
124131
{title: 'Timeline', tags: 'timeline', screen: 'unicorn.components.TimelineScreen'},
125132
{
126133
title: 'withScrollEnabler',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import React, {useCallback, useRef, useState} from 'react';
2+
import {Alert} from 'react-native';
3+
import {Colors, View, Text, Switch, SearchInput, SearchInputRef, Button, Icon, Assets} from 'react-native-ui-lib';
4+
5+
const SearchInputScreen = () => {
6+
const [showCancelBtn, setShowCancelBtn] = useState(false);
7+
const [showLoader, setShowLoader] = useState(false);
8+
const [showCustomRightElement, setShowCustomRightElement] = useState(false);
9+
const searchInput = useRef<SearchInputRef>();
10+
11+
const onChangeText = (text: string) => {
12+
console.log('UILIB text: ', text);
13+
};
14+
15+
const onDismiss = useCallback(() => {
16+
Alert.alert('Cancel was pressed');
17+
}, []);
18+
19+
const customRightElement = (
20+
<View center marginH-s2>
21+
<Icon source={Assets.icons.demo.check}/>
22+
</View>
23+
);
24+
25+
return (
26+
<View style={{marginVertical: 5}}>
27+
<Text center h3 $textDefault margin-5>
28+
SearchInput
29+
</Text>
30+
31+
<View>
32+
<SearchInput
33+
showLoader={showLoader}
34+
ref={searchInput}
35+
testID={'searchInput'}
36+
value=""
37+
placeholder="Search"
38+
onDismiss={showCancelBtn ? onDismiss : undefined}
39+
cancelButtonProps={{label: 'Cancel'}}
40+
customRightElement={showCustomRightElement ? customRightElement : undefined}
41+
/>
42+
<View marginV-s2>
43+
<SearchInput
44+
showLoader={showLoader}
45+
invertColors
46+
value={''}
47+
placeholder="Search with inverted colors"
48+
style={{backgroundColor: Colors.$backgroundNeutralHeavy}}
49+
onDismiss={showCancelBtn ? onDismiss : undefined}
50+
cancelButtonProps={{label: 'Cancel'}}
51+
onChangeText={onChangeText}
52+
customRightElement={showCustomRightElement ? customRightElement : undefined}
53+
/>
54+
</View>
55+
<SearchInput
56+
showLoader={showLoader}
57+
value={''}
58+
placeholder="Search with custom colors"
59+
onDismiss={showCancelBtn ? onDismiss : undefined}
60+
cancelButtonProps={{label: 'Cancel'}}
61+
onChangeText={onChangeText}
62+
style={{backgroundColor: Colors.purple20}}
63+
placeholderTextColor={Colors.white}
64+
containerStyle={{color: Colors.white}}
65+
customRightElement={showCustomRightElement ? customRightElement : undefined}
66+
/>
67+
</View>
68+
69+
<View marginV-s2>
70+
<Text center h3 $textDefault margin-5>
71+
Search Input Presets:
72+
</Text>
73+
<View margin-s2>
74+
<Text marginL-s3 marginV-s2>
75+
Default:
76+
</Text>
77+
<SearchInput
78+
showLoader={showLoader}
79+
testID={'searchInput'}
80+
value=""
81+
placeholder="Search"
82+
onDismiss={showCancelBtn ? onDismiss : undefined}
83+
cancelButtonProps={{label: 'Cancel'}}
84+
customRightElement={showCustomRightElement ? customRightElement : undefined}
85+
/>
86+
</View>
87+
<Text marginL-s3 marginV-s2>
88+
Prominent:
89+
</Text>
90+
<SearchInput
91+
showLoader={showLoader}
92+
testID={'searchInput'}
93+
value=""
94+
placeholder="Search"
95+
onDismiss={showCancelBtn ? onDismiss : undefined}
96+
cancelButtonProps={{label: 'Cancel'}}
97+
preset={'prominent'}
98+
customRightElement={showCustomRightElement ? customRightElement : undefined}
99+
/>
100+
</View>
101+
102+
<View marginT-s8 marginH-s3>
103+
<Text bodyBold>Settings:</Text>
104+
<View row marginV-s2>
105+
<Switch
106+
value={showCancelBtn}
107+
onValueChange={value => setShowCancelBtn(value)}
108+
onColor={Colors.$iconSuccessLight}
109+
/>
110+
<Text marginL-s4>Toggle cancel button</Text>
111+
</View>
112+
<View row marginV-s2>
113+
<Switch
114+
value={showCustomRightElement}
115+
onValueChange={value => setShowCustomRightElement(value)}
116+
onColor={Colors.$iconSuccessLight}
117+
/>
118+
<Text marginL-s4>Toggle Custom right element</Text>
119+
</View>
120+
<View row marginV-s2>
121+
<Switch value={showLoader} onValueChange={value => setShowLoader(value)} onColor={Colors.$iconSuccessLight}/>
122+
<Text marginL-s4>Toggle loader</Text>
123+
</View>
124+
<View padding-10 marginV-s1>
125+
<Text>Actions: on the first example</Text>
126+
<View row spread marginV-s1>
127+
<Button size={Button.sizes.small} label={'Blur'} onPress={() => searchInput?.current?.blur()}/>
128+
<Button size={Button.sizes.small} label={'Focus'} onPress={() => searchInput?.current?.focus()}/>
129+
<Button size={Button.sizes.small} label={'Clear'} onPress={() => searchInput?.current?.clear()}/>
130+
</View>
131+
</View>
132+
</View>
133+
</View>
134+
);
135+
};
136+
137+
export default SearchInputScreen;

demo/src/screens/componentScreens/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function registerScreens(registrar) {
4242
registrar('unicorn.components.RadioButtonScreen', () => require('./RadioButtonScreen').default);
4343
registrar('unicorn.components.ScrollBarScreen', () => require('./ScrollBarScreen').default);
4444
registrar('unicorn.components.SectionsWheelPickerScreen', () => require('./SectionsWheelPickerScreen').default);
45+
registrar('unicorn.components.SearchInputScreen', () => require('./SearchInputScreen').default);
4546
registrar('unicorn.components.SegmentedControlScreen', () => require('./SegmentedControlScreen').default);
4647
registrar('unicorn.components.SharedTransitionScreen', () => require('./SharedTransitionScreen').default);
4748
registrar('unicorn.components.SkeletonViewScreen', () => require('./SkeletonViewScreen').default);
@@ -53,7 +54,8 @@ export function registerScreens(registrar) {
5354
registrar('unicorn.components.StepperScreen', () => require('./StepperScreen').default);
5455
registrar('unicorn.components.SwitchScreen', () => require('./SwitchScreen').default);
5556
registrar('unicorn.components.TabControllerScreen', () => require('./TabControllerScreen').default);
56-
registrar('unicorn.components.TabControllerWithStickyHeaderScreen', () => require('./TabControllerWithStickyHeaderScreen').default);
57+
registrar('unicorn.components.TabControllerWithStickyHeaderScreen',
58+
() => require('./TabControllerWithStickyHeaderScreen').default);
5759
registrar('unicorn.components.TextFieldScreen', () => require('./TextFieldScreen').default);
5860
registrar('unicorn.components.TextScreen', () => require('./TextScreen').default);
5961
registrar('unicorn.components.ToastsScreen', () => require('./ToastsScreen').default);

docuilib/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uilib-docs",
3-
"version": "3.26.0",
3+
"version": "3.29.0",
44
"main": "./src/index.ts",
55
"scripts": {
66
"docusaurus": "docusaurus",

docuilib/sidebars.js

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ module.exports = {
6464
type: 'category',
6565
label: componentsCategories[category],
6666
collapsed: true,
67+
link: {
68+
type: 'generated-index',
69+
keywords: [category]
70+
},
6771
items: [
6872
{
6973
type: 'autogenerated',

docuilib/src/components/ColorsSection.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ export function ColorsTable() {
7575
}
7676
}));
7777

78-
const onTokenPress = value => {
79-
Clipboard.setString(value);
80-
const systemColorName = Colors.getSystemColorByHex(value);
81-
const message = `Copied ${value} to clipboard\n System color: ${systemColorName}`;
78+
const onTokenPress = ({token, value}) => {
79+
Clipboard.setString(token);
80+
const message = `Copied ${token} to clipboard\nHex: ${value}`;
8281
setMessage(message);
8382
toggleToastVisibility();
8483
};
@@ -92,7 +91,7 @@ export function ColorsTable() {
9291
};
9392

9493
const TokenBox = ({token, index, mode, onPress}) => (
95-
<TouchableOpacity onPress={() => onPress(Colors.getColor(token, mode))} flex marginV-s1>
94+
<TouchableOpacity onPress={() => onPress({token, value: Colors.getColor(token, mode)})} flex marginV-s1>
9695
<View key={`${token}-${index}-${mode}-container`} center row marginB-3>
9796
<View
9897
key={`${token}-${index}-${mode}`}

docuilib/src/components/UILivePreview.module.scss

+18-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ $editor-height: 700px;
44

55
.container {
66
display: flex;
7-
background-color: #1D1E21;
7+
background-color: #1d1e21;
88
border-radius: 8px;
9-
padding: 50px
9+
padding: 50px;
1010
}
1111

1212
.liveEditor {
1313
height: $editor-height;
1414

1515
span {
16-
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
16+
font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
1717
font-size: 14px;
1818
font-weight: 600;
1919
line-height: 24px;
@@ -32,19 +32,29 @@ $editor-height: 700px;
3232
pre {
3333
min-height: 100%;
3434
padding: 20px !important;
35-
background-color: #1D1E21 !important;
36-
border-right: 1px solid #D2D6D8;
35+
background-color: #1d1e21 !important;
36+
border-right: 1px solid #d2d6d8;
3737
}
3838
}
3939

40+
.codeHeader {
41+
position: sticky;
42+
top: 5px;
43+
right: 16px;
44+
z-index: 1;
45+
margin-right: 24px;
46+
display: flex;
47+
justify-content: flex-end;
48+
}
49+
4050
.errorContainer {
4151
position: absolute;
4252
bottom: 0;
4353
left: 0;
4454
right: 0;
4555

4656
pre {
47-
background-color: rgba(255, 255, 255, 0.80) !important;
57+
background-color: rgba(255, 255, 255, 0.8) !important;
4858
margin: 10px;
4959
}
5060
}
@@ -54,7 +64,7 @@ $editor-height: 700px;
5464
width: $preview-width;
5565
margin-left: $preview-margin;
5666
border-radius: 36px;
57-
border: 10px solid rgba(255, 255, 255, 0.20);
67+
border: 10px solid rgba(255, 255, 255, 0.2);
5868
box-shadow: 0 0 15px rgba(110, 120, 129, 0.05);
5969
overflow: hidden;
6070
}
@@ -68,4 +78,4 @@ $editor-height: 700px;
6878
border: 0;
6979
padding: 10;
7080
background-color: #fff;
71-
}
81+
}

docuilib/src/components/UILivePreview.tsx

+16-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {themes} from 'prism-react-renderer';
44
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
55
import BrowserOnly from '@docusaurus/BrowserOnly';
66
import CodeBlock from '@theme/CodeBlock';
7+
import {Button} from 'react-native-ui-lib/core';
78
import ReactLiveScope from '../theme/ReactLiveScope';
89
import {isComponentSupported} from '../utils/componentUtils';
910
import useFormattedCode from '../hooks/useFormattedCode';
@@ -15,12 +16,8 @@ export default function UILivePreview({code: initialCode, componentName = undefi
1516
const [iframeLoaded, setIframeLoaded] = useState(false);
1617
const {siteConfig} = useDocusaurusContext();
1718
const iframeRef = useRef(null);
18-
const {code: formattedCode} = useFormattedCode(initialCode, {printWidth: 100});
19-
const [code, setCode] = useState(formattedCode);
20-
21-
useEffect(() => {
22-
setCode(formattedCode);
23-
}, [formattedCode]);
19+
const [code, setCode] = useState(initialCode);
20+
const {code: formattedCode} = useFormattedCode(code, {printWidth: 100});
2421

2522
useEffect(() => {
2623
if (iframeLoaded) {
@@ -33,6 +30,10 @@ export default function UILivePreview({code: initialCode, componentName = undefi
3330
iframeRef.current?.contentWindow.postMessage(message, '*');
3431
};
3532

33+
const handleFormat = () => {
34+
setCode(formattedCode);
35+
};
36+
3637
if (!liveScopeSupport && !isComponentSupported(componentName)) {
3738
return <CodeBlock language="jsx">{code}</CodeBlock>;
3839
}
@@ -46,6 +47,15 @@ export default function UILivePreview({code: initialCode, componentName = undefi
4647
<LiveProvider code={code} scope={ReactLiveScope} theme={themes.oceanicNext}>
4748
<div className={styles.container}>
4849
<div className={styles.codeContainer}>
50+
<div className={styles.codeHeader}>
51+
<Button
52+
label="Prettify"
53+
size={Button.sizes.small}
54+
onPress={handleFormat}
55+
backgroundColor="#2d2d2d"
56+
borderRadius={4}
57+
/>
58+
</div>
4959
<LiveEditor onChange={setCode} className={styles.liveEditor}/>
5060
<div className={styles.errorContainer}>
5161
<LiveError/>

0 commit comments

Comments
 (0)