From 1153ecaaf8fad4089c4a47aa2d8475915d5fd744 Mon Sep 17 00:00:00 2001 From: Abi Fadhillah Surya Date: Sat, 24 Oct 2020 01:27:03 +0700 Subject: [PATCH 1/3] feat: Add Custom Font Weight Styling --- README.md | 2 ++ js/SegmentedControlTab.js | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b7d0d962..574e192b 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ An object container - `color`: color of segment text - `fontSize`: font-size of segment text - `fontFamily`: font-family of segment text +- `fontWeight`: font-weight of segment text ### `activeFontStyle` @@ -213,6 +214,7 @@ An object container - `color`: overrides color of selected segment text - `fontSize`: overrides font-size of selected segment text - `fontFamily`: overrides font-family of selected segment text +- `fontWeight`: overrides font-weight of selected segment text ## Maintainers diff --git a/js/SegmentedControlTab.js b/js/SegmentedControlTab.js index 85c1c7a1..ea6f3314 100644 --- a/js/SegmentedControlTab.js +++ b/js/SegmentedControlTab.js @@ -45,12 +45,13 @@ export const SegmentedControlTab = ({ }: Props): React.Node => { const colorSchemeHook = useColorScheme(); const colorScheme = appearance || colorSchemeHook; - const {color: textColor, fontSize, fontFamily} = fontStyle; + const {color: textColor, fontSize, fontFamily, fontWeight} = fontStyle; const { color: activeColor, fontSize: activeFontSize, fontFamily: activeFontFamily, + fontWeight: activeFontWeight, } = activeFontStyle; const getColor = () => { @@ -69,12 +70,14 @@ export const SegmentedControlTab = ({ fontFamily: activeFontFamily || fontFamily, fontSize: activeFontSize || fontSize, color: activeColor || color, + fontWeight: activeFontWeight || fontWeight || styles.activeText.fontWeight, }; const idleStyle = { color, fontSize: fontSize, fontFamily: fontFamily, + fontWeight: fontWeight, }; return ( From 1cd69d22cdd8064ca490fdd12d5d45621de0aa8b Mon Sep 17 00:00:00 2001 From: Abi Fadhillah Surya Date: Sun, 25 Oct 2020 00:40:59 +0700 Subject: [PATCH 2/3] fix: add missing fontWeight prop-types --- js/types.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/types.js b/js/types.js index 1629a6d8..609d85f0 100644 --- a/js/types.js +++ b/js/types.js @@ -26,6 +26,10 @@ export type FontStyle = $ReadOnly<{| * Font Family of the Segmented Control */ fontFamily?: string, + /** + * Font Weight of the Segmented Control + */ + fontWeight?: string, |}>; export type SegmentedControlProps = $ReadOnly<{| From cc53180e664bf40b52a661a2b5d3e1a0edd6b4c2 Mon Sep 17 00:00:00 2001 From: Abi Fadhillah Surya Date: Sun, 25 Oct 2020 01:04:55 +0700 Subject: [PATCH 3/3] fix: fontWeight prop-type validation --- js/types.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/types.js b/js/types.js index 609d85f0..de716f9c 100644 --- a/js/types.js +++ b/js/types.js @@ -29,7 +29,18 @@ export type FontStyle = $ReadOnly<{| /** * Font Weight of the Segmented Control */ - fontWeight?: string, + fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', |}>; export type SegmentedControlProps = $ReadOnly<{|