Skip to content

Instantly share code, notes, and snippets.

@coolsoftwaretyler
Last active December 29, 2023 21:15
Show Gist options
  • Save coolsoftwaretyler/5b9c4bf15cdbcc4c5b132a4082b0f767 to your computer and use it in GitHub Desktop.
Save coolsoftwaretyler/5b9c4bf15cdbcc4c5b132a4082b0f767 to your computer and use it in GitHub Desktop.

Revisions

  1. coolsoftwaretyler revised this gist Dec 29, 2023. No changes.
  2. coolsoftwaretyler revised this gist Dec 29, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Text.tsx
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ export interface TextProps extends RNTextProps {
    color?: string;
    }

    export function Text(props: TextProps) {
    export function BrandText(props: TextProps) {
    const {
    text,
    preset = 'body',
  3. coolsoftwaretyler revised this gist Dec 26, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Text.tsx
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ const styles = StyleSheet.create({
    fontWeight: 'normal',
    lineHeight: 24,
    },
    defaultColor: { color: '#000000' }, // Assuming richBlack color for default text color
    defaultColor: { color: '#000000' },
    });

    type PresetNames = 'header' | 'subheader' | 'body';
  4. coolsoftwaretyler created this gist Dec 26, 2023.
    55 changes: 55 additions & 0 deletions Text.tsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    import React from 'react';
    import {
    StyleSheet,
    Text as RNText,
    TextProps as RNTextProps,
    TextStyle,
    } from 'react-native';

    const styles = StyleSheet.create({
    header: {
    fontSize: 32,
    fontWeight: 'bold',
    lineHeight: 40,
    textTransform: 'uppercase',
    },
    subheader: {
    fontSize: 24,
    fontWeight: '600',
    lineHeight: 30,
    },
    body: {
    fontSize: 16,
    fontWeight: 'normal',
    lineHeight: 24,
    },
    defaultColor: { color: '#000000' }, // Assuming richBlack color for default text color
    });

    type PresetNames = 'header' | 'subheader' | 'body';

    export interface TextProps extends RNTextProps {
    text?: string;
    preset?: PresetNames;
    color?: string;
    }

    export function Text(props: TextProps) {
    const {
    text,
    preset = 'body',
    color = styles.defaultColor.color,
    style,
    ...rest
    } = props;

    const presetStyle = styles[preset] || styles.body;
    const colorStyle = { color };
    const combinedStyles = [presetStyle, colorStyle, style];

    return (
    <RNText {...rest} style={combinedStyles}>
    {text}
    </RNText>
    );
    }