Skip to content

Feat/text add underline #1670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import {Animated, ScrollView} from 'react-native';
import {View, Text, Colors} from 'react-native-ui-lib';

class TextScreen extends Component {
state = {};
toggle = false;
animatedValue = new Animated.Value(0);
private toggle = false;
private animatedValue = new Animated.Value(0);

animate = () => {
this.toggle = !this.toggle;
Expand Down Expand Up @@ -89,6 +88,7 @@ class TextScreen extends Component {
<Text
text70
animated
// @ts-expect-error
style={{transform: [{scale: this.animatedValue.interpolate({inputRange: [0, 1], outputRange: [1, 2]})}]}}
onPress={this.animate}
>
Expand Down
8 changes: 6 additions & 2 deletions generatedTypes/src/components/text/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ export declare type TextProps = RNTextProps & TypographyModifiers & ColorsModifi
*/
color?: string;
/**
* whether to center the text (using textAlign)
* Whether to center the text (using textAlign)
*/
center?: boolean;
/**
* whether to change the text to uppercase
* Whether to change the text to uppercase
*/
uppercase?: boolean;
/**
* Whether to add an underline
*/
underline?: boolean;
/**
* Substring to highlight
*/
Expand Down
14 changes: 11 additions & 3 deletions src/components/text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ export type TextProps = RNTextProps &
*/
color?: string;
/**
* whether to center the text (using textAlign)
* Whether to center the text (using textAlign)
*/
center?: boolean;
/**
* whether to change the text to uppercase
* Whether to change the text to uppercase
*/
uppercase?: boolean;
/**
* Whether to add an underline
*/
underline?: boolean;
/**
* Substring to highlight
*/
Expand Down Expand Up @@ -97,7 +101,7 @@ class Text extends PureComponent<PropsTypes> {
}

render() {
const {modifiers, style, center, uppercase, children, forwardedRef, ...others} = this.props;
const {modifiers, style, center, uppercase, underline, children, forwardedRef, ...others} = this.props;
const color = this.props.color || modifiers.color;
const {margins, typography, backgroundColor, flexStyle} = modifiers;
const textStyle = [
Expand All @@ -109,6 +113,7 @@ class Text extends PureComponent<PropsTypes> {
margins,
center && styles.centered,
uppercase && styles.uppercase,
underline && styles.underline,
style
];

Expand All @@ -133,6 +138,9 @@ const styles = StyleSheet.create({
uppercase: {
textTransform: 'uppercase'
},
underline: {
textDecorationLine: 'underline'
},
highlight: {
color: Colors.grey30
},
Expand Down
1 change: 1 addition & 0 deletions src/components/text/text.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{"name": "color", "type": "string", "description": "Color of the text"},
{"name": "center", "type": "boolean", "description": "Whether to center the text (using textAlign)"},
{"name": "uppercase", "type": "boolean", "description": "Whether to change the text to uppercase"},
{"name": "underline", "type": "boolean", "description": "Whether to add an underline"},
{"name": "highlightString", "type": "string | string[]", "description": "Substring to highlight"},
{"name": "highlightStyle", "type": "TextStyle", "description": "Custom highlight style for highlight string"},
{"name": "animated", "type": "boolean", "description": "Use Animated.Text as a container"}
Expand Down