Skip to content

Commit 1228ea4

Browse files
authored
Merge pull request #7 from buraksakalli/feature/custom-border
Feature/custom border
2 parents 4909a24 + 4a0a2b5 commit 1228ea4

File tree

6 files changed

+37
-12
lines changed

6 files changed

+37
-12
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ A simple select component for React Native.
1717
- [ ] Add support for placeholder color
1818
- [ ] Add tests
1919
- [ ] Add support for custom components
20-
- [ ] Add support for custom styles
20+
- [x] Add support for custom styles
2121
- [ ] Add support for custom placeholder
2222
- [ ] Add support for validation
2323
- [ ] GitHub Actions for CI/CD
@@ -52,6 +52,7 @@ const App = () => {
5252
value={value}
5353
onChange={(option) => setValue(option)}
5454
disabledOptions={[options[1]]}
55+
borderColor="red"
5556
/>
5657
</View>
5758
);
@@ -76,6 +77,7 @@ const App = () => {
7677
| optionContainerTextStyle | Object | | Style object to be applied to the option container text |
7778
| optionSelectedStyle | Object | | Style object to be applied to the selected option |
7879
| optionSelectedTextStyle | Object | | Style object to be applied to the selected option text |
80+
| borderColor | String | #999 | Border color of the container |
7981

8082
## Contributing
8183

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ PODS:
623623
- React-jsinspector (0.68.2)
624624
- React-logger (0.68.2):
625625
- glog
626-
- react-native-select (0.1.1):
626+
- react-native-select (0.2.0):
627627
- RCT-Folly
628628
- RCTRequired
629629
- RCTTypeSafety
@@ -904,7 +904,7 @@ SPEC CHECKSUMS:
904904
React-jsiexecutor: b7b553412f2ec768fe6c8f27cd6bafdb9d8719e6
905905
React-jsinspector: c5989c77cb89ae6a69561095a61cce56a44ae8e8
906906
React-logger: a0833912d93b36b791b7a521672d8ee89107aff1
907-
react-native-select: 91e79136b322658dfce6ea45656073dfd97c9a29
907+
react-native-select: c29b2d39ead34427b10172b95f3d563486a9d12b
908908
React-perflogger: a18b4f0bd933b8b24ecf9f3c54f9bf65180f3fe6
909909
React-RCTActionSheet: 547fe42fdb4b6089598d79f8e1d855d7c23e2162
910910
React-RCTAnimation: bc9440a1c37b06ae9ebbb532d244f607805c6034

example/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export default function App() {
2424
onChange={(option) => setValue(option)}
2525
color="red"
2626
placeholder="Select your favorite flavor"
27+
disabledOptions={[options[1]]}
28+
borderColor="red"
2729
/>
2830
<View style={styles.gap} />
2931
<Select

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-multi-options",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A simple select component for React Native.",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

src/components/Select/Select.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type SelectOption = {
1212
type ISelect = {
1313
search?: boolean;
1414
disabledOptions?: Array<SelectOption>;
15+
borderColor?: string;
1516
};
1617

1718
interface MultipleSelectProps extends ISelect {
@@ -40,6 +41,7 @@ export const Select: React.FC<SelectProps> = ({
4041
color = 'blue',
4142
placeholder,
4243
disabledOptions,
44+
borderColor,
4345
}) => {
4446
const [isOpen, setIsOpen] = useState(false);
4547
const [activeColor, setActiveColor] = useState<string>(colorMatch(color));
@@ -74,7 +76,7 @@ export const Select: React.FC<SelectProps> = ({
7476
<View style={styles.wrapper}>
7577
<TouchableOpacity
7678
onBlur={() => setIsOpen(false)}
77-
style={styles.container}
79+
style={[styles.container, borderColor ? { borderColor } : {}]}
7880
activeOpacity={0.7}
7981
onPress={() => setIsOpen((prev) => !prev)}
8082
>
@@ -101,12 +103,28 @@ export const Select: React.FC<SelectProps> = ({
101103
<View style={styles.settings}>
102104
{multiple && value.length > 0 && (
103105
<TouchableOpacity style={styles.remove} onPress={clearOptions}>
104-
<Text>&times;</Text>
106+
<Text
107+
style={[styles.text, borderColor ? { color: borderColor } : {}]}
108+
>
109+
&times;
110+
</Text>
105111
</TouchableOpacity>
106112
)}
107-
<View style={styles.divider} />
113+
<View
114+
style={[
115+
styles.divider,
116+
borderColor ? { backgroundColor: borderColor } : {},
117+
]}
118+
/>
108119
<TouchableOpacity onPress={() => setIsOpen((prev) => !prev)}>
109-
<Text style={[styles.caret, isOpen ? styles.caretOpen : {}]}>
120+
<Text
121+
style={[
122+
styles.text,
123+
styles.caret,
124+
isOpen ? styles.caretOpen : {},
125+
borderColor ? { color: borderColor } : {},
126+
]}
127+
>
110128
^
111129
</Text>
112130
</TouchableOpacity>

src/components/Select/select.style.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const styles = StyleSheet.create({
1212
justifyContent: 'space-between',
1313
alignItems: 'center',
1414
borderWidth: 1,
15-
borderColor: '#28282850',
15+
borderColor: '#404243',
1616
},
1717
button: {
1818
backgroundColor: 'green',
@@ -41,7 +41,7 @@ export const styles = StyleSheet.create({
4141
},
4242
remove: {},
4343
divider: {
44-
backgroundColor: '#28282850',
44+
backgroundColor: '#404243',
4545
alignSelf: 'stretch',
4646
width: 1,
4747
marginHorizontal: 10,
@@ -51,7 +51,7 @@ export const styles = StyleSheet.create({
5151
flexWrap: 'wrap',
5252
marginTop: 5,
5353
borderWidth: 1,
54-
borderColor: '#28282850',
54+
borderColor: '#404243',
5555
borderRadius: 13,
5656
padding: 10,
5757
},
@@ -70,9 +70,12 @@ export const styles = StyleSheet.create({
7070
marginBottom: -5,
7171
},
7272
placeholder: {
73-
color: '#28282850',
73+
color: '#404243',
7474
},
7575
disabled: {
7676
opacity: 0.5,
7777
},
78+
text: {
79+
color: '#404243',
80+
},
7881
});

0 commit comments

Comments
 (0)