@metamask-previews/design-system-react-native 0.0.0-preview.f4da8f1 → 0.0.0-preview.fbd1fe9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/Button.constants.d.ts +2 -0
- package/dist/components/Button/Button.constants.d.ts.map +1 -0
- package/dist/components/Button/Button.constants.js +7 -0
- package/dist/components/Button/Button.constants.js.map +1 -0
- package/dist/components/Button/Button.d.ts +5 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +25 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/Button.types.d.ts +23 -0
- package/dist/components/Button/Button.types.d.ts.map +1 -0
- package/dist/components/Button/Button.types.js +15 -0
- package/dist/components/Button/Button.types.js.map +1 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.js +12 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.d.ts +3 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.js +29 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.ts +5 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.js +97 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.d.ts +17 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.js +3 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.d.ts +78 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.js +122 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/index.d.ts +4 -0
- package/dist/components/Button/variants/ButtonPrimary/index.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/index.js +11 -0
- package/dist/components/Button/variants/ButtonPrimary/index.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.d.ts +3 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.js +29 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.ts +5 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.js +90 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.d.ts +17 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.js +3 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.d.ts +90 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.js +145 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/index.d.ts +4 -0
- package/dist/components/Button/variants/ButtonSecondary/index.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/index.js +11 -0
- package/dist/components/Button/variants/ButtonSecondary/index.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.d.ts +3 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.js +29 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.ts +5 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.js +90 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.d.ts +17 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.js +3 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.d.ts +88 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.js +147 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/index.d.ts +4 -0
- package/dist/components/Button/variants/ButtonTertiary/index.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/index.js +11 -0
- package/dist/components/Button/variants/ButtonTertiary/index.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.d.ts +6 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.js +20 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.d.ts +5 -0
- package/dist/components/ButtonIcon/ButtonIcon.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.js +72 -0
- package/dist/components/ButtonIcon/ButtonIcon.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.d.ts +60 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.js +19 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.d.ts +55 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.js +73 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.js.map +1 -0
- package/dist/components/ButtonIcon/index.d.ts +4 -0
- package/dist/components/ButtonIcon/index.d.ts.map +1 -0
- package/dist/components/ButtonIcon/index.js +11 -0
- package/dist/components/ButtonIcon/index.js.map +1 -0
- package/dist/components/Icon/Icon.assets.d.ts +6 -0
- package/dist/components/Icon/Icon.assets.d.ts.map +1 -0
- package/dist/components/Icon/Icon.assets.js +324 -0
- package/dist/components/Icon/Icon.assets.js.map +1 -0
- package/dist/components/Icon/Icon.constants.d.ts +7 -0
- package/dist/components/Icon/Icon.constants.d.ts.map +1 -0
- package/dist/components/Icon/Icon.constants.js +15 -0
- package/dist/components/Icon/Icon.constants.js.map +1 -0
- package/dist/components/Icon/Icon.d.ts +5 -0
- package/dist/components/Icon/Icon.d.ts.map +1 -0
- package/dist/components/Icon/Icon.js +45 -0
- package/dist/components/Icon/Icon.js.map +1 -0
- package/dist/components/Icon/Icon.types.d.ts +254 -0
- package/dist/components/Icon/Icon.types.d.ts.map +1 -0
- package/dist/components/Icon/Icon.types.js +229 -0
- package/dist/components/Icon/Icon.types.js.map +1 -0
- package/dist/components/Icon/Icon.utilities.d.ts +22 -0
- package/dist/components/Icon/Icon.utilities.d.ts.map +1 -0
- package/dist/components/Icon/Icon.utilities.js +31 -0
- package/dist/components/Icon/Icon.utilities.js.map +1 -0
- package/dist/components/Icon/index.d.ts +4 -0
- package/dist/components/Icon/index.d.ts.map +1 -0
- package/dist/components/Icon/index.js +13 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/components/Text/Text.constants.d.ts +9 -0
- package/dist/components/Text/Text.constants.d.ts.map +1 -0
- package/dist/components/Text/Text.constants.js +21 -0
- package/dist/components/Text/Text.constants.js.map +1 -0
- package/dist/components/Text/Text.d.ts +5 -0
- package/dist/components/Text/Text.d.ts.map +1 -0
- package/dist/components/Text/Text.js +26 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Text/Text.types.d.ts +110 -0
- package/dist/components/Text/Text.types.d.ts.map +1 -0
- package/dist/components/Text/Text.types.js +89 -0
- package/dist/components/Text/Text.types.js.map +1 -0
- package/dist/components/Text/Text.utilities.d.ts +30 -0
- package/dist/components/Text/Text.utilities.d.ts.map +1 -0
- package/dist/components/Text/Text.utilities.js +45 -0
- package/dist/components/Text/Text.utilities.js.map +1 -0
- package/dist/components/Text/index.d.ts +4 -0
- package/dist/components/Text/index.d.ts.map +1 -0
- package/dist/components/Text/index.js +14 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/TextButton/TextButton.constants.d.ts +3 -0
- package/dist/components/TextButton/TextButton.constants.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.constants.js +29 -0
- package/dist/components/TextButton/TextButton.constants.js.map +1 -0
- package/dist/components/TextButton/TextButton.d.ts +5 -0
- package/dist/components/TextButton/TextButton.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.js +187 -0
- package/dist/components/TextButton/TextButton.js.map +1 -0
- package/dist/components/TextButton/TextButton.types.d.ts +73 -0
- package/dist/components/TextButton/TextButton.types.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.types.js +3 -0
- package/dist/components/TextButton/TextButton.types.js.map +1 -0
- package/dist/components/TextButton/TextButton.utilities.d.ts +55 -0
- package/dist/components/TextButton/TextButton.utilities.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.utilities.js +77 -0
- package/dist/components/TextButton/TextButton.utilities.js.map +1 -0
- package/dist/components/TextButton/index.d.ts +3 -0
- package/dist/components/TextButton/index.d.ts.map +1 -0
- package/dist/components/TextButton/index.js +9 -0
- package/dist/components/TextButton/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.d.ts +5 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.d.ts.map +1 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.js +58 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.js.map +1 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.d.ts +6 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.d.ts.map +1 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.js +3 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.js.map +1 -0
- package/dist/primitives/ButtonAnimated/index.d.ts +2 -0
- package/dist/primitives/ButtonAnimated/index.d.ts.map +1 -0
- package/dist/primitives/ButtonAnimated/index.js +9 -0
- package/dist/primitives/ButtonAnimated/index.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.d.ts +3 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.js +32 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.d.ts +5 -0
- package/dist/primitives/ButtonBase/ButtonBase.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.js +84 -0
- package/dist/primitives/ButtonBase/ButtonBase.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.d.ts +93 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.js +19 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.d.ts +28 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.js +41 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.js.map +1 -0
- package/dist/primitives/ButtonBase/index.d.ts +4 -0
- package/dist/primitives/ButtonBase/index.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/index.js +11 -0
- package/dist/primitives/ButtonBase/index.js.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.d.ts +5 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.d.ts.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.js +15 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.js.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.d.ts +15 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.d.ts.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.js +3 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.js.map +1 -0
- package/dist/temp-components/Spinner/Spinner.constants.d.ts +3 -0
- package/dist/temp-components/Spinner/Spinner.constants.d.ts.map +1 -0
- package/dist/temp-components/Spinner/Spinner.constants.js +21 -0
- package/dist/temp-components/Spinner/Spinner.constants.js.map +1 -0
- package/dist/temp-components/Spinner/Spinner.d.ts +5 -0
- package/dist/temp-components/Spinner/Spinner.d.ts.map +1 -0
- package/dist/temp-components/Spinner/Spinner.js +68 -0
- package/dist/temp-components/Spinner/Spinner.js.map +1 -0
- package/dist/temp-components/Spinner/Spinner.types.d.ts +30 -0
- package/dist/temp-components/Spinner/Spinner.types.d.ts.map +1 -0
- package/dist/temp-components/Spinner/Spinner.types.js +3 -0
- package/dist/temp-components/Spinner/Spinner.types.js.map +1 -0
- package/dist/temp-components/Spinner/index.d.ts +3 -0
- package/dist/temp-components/Spinner/index.d.ts.map +1 -0
- package/dist/temp-components/Spinner/index.js +9 -0
- package/dist/temp-components/Spinner/index.js.map +1 -0
- package/package.json +12 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.constants.js","sourceRoot":"","sources":["../../../src/components/Text/Text.constants.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;AAGjD,6CAAkE;AAElE,WAAW;AACE,QAAA,oBAAoB,GAAG,wBAAW,CAAC,MAAM,CAAC;AAC1C,QAAA,kBAAkB,GAAG,sBAAS,CAAC,WAAW,CAAC;AAExD,WAAW;AACE,QAAA,8CAA8C,GAEvD;IACF,CAAC,uBAAU,CAAC,MAAM,CAAC,EAAE,EAAE;IACvB,CAAC,uBAAU,CAAC,MAAM,CAAC,EAAE,SAAS;IAC9B,CAAC,uBAAU,CAAC,IAAI,CAAC,EAAE,OAAO;CAC3B,CAAC;AAEF,gBAAgB;AACH,QAAA,iBAAiB,GAAc;IAC1C,OAAO,EAAE,4BAAoB;IAC7B,QAAQ,EAAE,aAAa;IACvB,KAAK,EAAE,0BAAkB;CAC1B,CAAC","sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nimport type { TextProps } from './Text.types';\nimport { FontWeight, TextColor, TextVariant } from './Text.types';\n\n// Defaults\nexport const DEFAULT_TEXT_VARIANT = TextVariant.BodyMd;\nexport const DEFAULT_TEXT_COLOR = TextColor.TextDefault;\n\n// Mappings\nexport const MAPPING_FONTWEIGHT_TO_FONTFAMILYSTYLECLASSNAME: {\n [key in FontWeight]: string;\n} = {\n [FontWeight.Normal]: '',\n [FontWeight.Medium]: '-medium',\n [FontWeight.Bold]: '-bold',\n};\n\n// Sample consts\nexport const SAMPLE_TEXT_PROPS: TextProps = {\n variant: DEFAULT_TEXT_VARIANT,\n children: 'Sample Text',\n color: DEFAULT_TEXT_COLOR,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CA4B7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const design_system_twrnc_preset_1 = require("@metamask-previews/design-system-twrnc-preset");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const Text_constants_1 = require("./Text.constants");
|
|
10
|
+
const Text_types_1 = require("./Text.types");
|
|
11
|
+
const Text_utilities_1 = require("./Text.utilities");
|
|
12
|
+
const Text = ({ variant = Text_constants_1.DEFAULT_TEXT_VARIANT, color = Text_constants_1.DEFAULT_TEXT_COLOR, style, children, fontWeight = Text_types_1.FontWeight.Normal, fontStyle = Text_types_1.FontStyle.Normal, twClassName = '', ...props }) => {
|
|
13
|
+
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
14
|
+
const mergedClassnames = (0, Text_utilities_1.generateTextClassNames)({
|
|
15
|
+
variant,
|
|
16
|
+
color,
|
|
17
|
+
fontWeight,
|
|
18
|
+
fontStyle,
|
|
19
|
+
twClassName,
|
|
20
|
+
});
|
|
21
|
+
return (<react_native_1.Text accessibilityRole="text" {...props} style={[tw `${mergedClassnames}`, style]}>
|
|
22
|
+
{children}
|
|
23
|
+
</react_native_1.Text>);
|
|
24
|
+
};
|
|
25
|
+
exports.default = Text;
|
|
26
|
+
//# sourceMappingURL=Text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":";;;;;AAAA,8FAA4E;AAC5E,kDAA0B;AAC1B,+CAA8C;AAE9C,qDAA4E;AAE5E,6CAAqD;AACrD,qDAA0D;AAE1D,MAAM,IAAI,GAAwB,CAAC,EACjC,OAAO,GAAG,qCAAoB,EAC9B,KAAK,GAAG,mCAAkB,EAC1B,KAAK,EACL,QAAQ,EACR,UAAU,GAAG,uBAAU,CAAC,MAAM,EAC9B,SAAS,GAAG,sBAAS,CAAC,MAAM,EAC5B,WAAW,GAAG,EAAE,EAChB,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,IAAA,wCAAW,GAAE,CAAC;IACzB,MAAM,gBAAgB,GAAG,IAAA,uCAAsB,EAAC;QAC9C,OAAO;QACP,KAAK;QACL,UAAU;QACV,SAAS;QACT,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,CACL,CAAC,mBAAM,CACL,iBAAiB,CAAC,MAAM,CACxB,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA,GAAG,gBAAgB,EAAE,EAAE,KAAK,CAAC,CAAC,CAExC;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,mBAAM,CAAC,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React from 'react';\nimport { Text as RNText } from 'react-native';\n\nimport { DEFAULT_TEXT_COLOR, DEFAULT_TEXT_VARIANT } from './Text.constants';\nimport type { TextProps } from './Text.types';\nimport { FontWeight, FontStyle } from './Text.types';\nimport { generateTextClassNames } from './Text.utilities';\n\nconst Text: React.FC<TextProps> = ({\n variant = DEFAULT_TEXT_VARIANT,\n color = DEFAULT_TEXT_COLOR,\n style,\n children,\n fontWeight = FontWeight.Normal,\n fontStyle = FontStyle.Normal,\n twClassName = '',\n ...props\n}) => {\n const tw = useTailwind();\n const mergedClassnames = generateTextClassNames({\n variant,\n color,\n fontWeight,\n fontStyle,\n twClassName,\n });\n\n return (\n <RNText\n accessibilityRole=\"text\"\n {...props}\n style={[tw`${mergedClassnames}`, style]}\n >\n {children}\n </RNText>\n );\n};\n\nexport default Text;\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { TextProps as RNTextProps } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Text component variants.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum TextVariant {
|
|
6
|
+
DisplayMd = "display-md",
|
|
7
|
+
HeadingLg = "heading-lg",
|
|
8
|
+
HeadingMd = "heading-md",
|
|
9
|
+
HeadingSm = "heading-sm",
|
|
10
|
+
BodyLg = "body-lg",
|
|
11
|
+
BodyMd = "body-md",
|
|
12
|
+
BodySm = "body-sm",
|
|
13
|
+
BodyXs = "body-xs"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Text colors
|
|
17
|
+
*/
|
|
18
|
+
export declare enum TextColor {
|
|
19
|
+
/** For default neutral text. */
|
|
20
|
+
TextDefault = "text-text-default",
|
|
21
|
+
/** For softer contrast neutral text */
|
|
22
|
+
TextAlternative = "text-text-alternative",
|
|
23
|
+
/** For the softest contrast neutral text (not accessible) */
|
|
24
|
+
TextMuted = "text-text-muted",
|
|
25
|
+
/** For elements used on top of overlay/alternative. */
|
|
26
|
+
OverlayInverse = "text-overlay-inverse",
|
|
27
|
+
/** For interactive, active, and selected semantics. */
|
|
28
|
+
PrimaryDefault = "text-primary-default",
|
|
29
|
+
/** For softer variants of primary text. */
|
|
30
|
+
PrimaryAlternative = "text-primary-alternative",
|
|
31
|
+
/** For elements used on top of primary/default. */
|
|
32
|
+
PrimaryInverse = "text-primary-inverse",
|
|
33
|
+
/** For primary text in a pressed state. */
|
|
34
|
+
PrimaryDefaultPressed = "text-primary-defaultPressed",
|
|
35
|
+
/** For critical alert text. */
|
|
36
|
+
ErrorDefault = "text-error-default",
|
|
37
|
+
/** For stronger contrast error text. */
|
|
38
|
+
ErrorAlternative = "text-error-alternative",
|
|
39
|
+
/** For elements used on top of error/default. */
|
|
40
|
+
ErrorInverse = "text-error-inverse",
|
|
41
|
+
/** For critical alert text in a pressed state. */
|
|
42
|
+
ErrorDefaultPressed = "text-error-defaultPressed",
|
|
43
|
+
/** For caution alert text. */
|
|
44
|
+
WarningDefault = "text-warning-default",
|
|
45
|
+
/** For elements used on top of warning/default. */
|
|
46
|
+
WarningInverse = "text-warning-inverse",
|
|
47
|
+
/** For caution text in a pressed state. */
|
|
48
|
+
WarningDefaultPressed = "text-warning-defaultPressed",
|
|
49
|
+
/** For positive semantic text. */
|
|
50
|
+
SuccessDefault = "text-success-default",
|
|
51
|
+
/** For elements used on top of success/default. */
|
|
52
|
+
SuccessInverse = "text-success-inverse",
|
|
53
|
+
/** For positive text in a pressed state. */
|
|
54
|
+
SuccessDefaultPressed = "text-success-defaultPressed",
|
|
55
|
+
/** For informational read-only text. */
|
|
56
|
+
InfoDefault = "text-info-default",
|
|
57
|
+
/** For elements used on top of info/default. */
|
|
58
|
+
InfoInverse = "text-info-inverse",
|
|
59
|
+
/** Make the text color transparent. */
|
|
60
|
+
Transparent = "text-transparent"
|
|
61
|
+
}
|
|
62
|
+
export declare enum FontWeight {
|
|
63
|
+
/**
|
|
64
|
+
* Weight - 700
|
|
65
|
+
*/
|
|
66
|
+
Bold = "700",
|
|
67
|
+
/**
|
|
68
|
+
* Weight - 500
|
|
69
|
+
*/
|
|
70
|
+
Medium = "500",
|
|
71
|
+
/**
|
|
72
|
+
* Weight - 400
|
|
73
|
+
*/
|
|
74
|
+
Normal = "400"
|
|
75
|
+
}
|
|
76
|
+
export declare enum FontStyle {
|
|
77
|
+
Italic = "italic",
|
|
78
|
+
Normal = "normal"
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Text component props.
|
|
82
|
+
*/
|
|
83
|
+
export type TextProps = {
|
|
84
|
+
/**
|
|
85
|
+
* Optional enum to select between Typography variants.
|
|
86
|
+
* @default BodyMD
|
|
87
|
+
*/
|
|
88
|
+
variant?: TextVariant;
|
|
89
|
+
/**
|
|
90
|
+
* Text to be displayed.
|
|
91
|
+
*/
|
|
92
|
+
children: React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Optional prop to add color to text.
|
|
95
|
+
*/
|
|
96
|
+
color?: TextColor;
|
|
97
|
+
/**
|
|
98
|
+
* Optional prop to adjust the weight of the font.
|
|
99
|
+
*/
|
|
100
|
+
fontWeight?: FontWeight;
|
|
101
|
+
/**
|
|
102
|
+
* Optional prop to adjust the style of the font.
|
|
103
|
+
*/
|
|
104
|
+
fontStyle?: FontStyle;
|
|
105
|
+
/**
|
|
106
|
+
* Optional prop to add twrnc overriding classNames.
|
|
107
|
+
*/
|
|
108
|
+
twClassName?: string;
|
|
109
|
+
} & RNTextProps;
|
|
110
|
+
//# sourceMappingURL=Text.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.types.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D;;GAEG;AACH,oBAAY,WAAW;IAErB,SAAS,eAAe;IAGxB,SAAS,eAAe;IACxB,SAAS,eAAe;IACxB,SAAS,eAAe;IAGxB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;CACnB;AAED;;GAEG;AACH,oBAAY,SAAS;IACnB,gCAAgC;IAChC,WAAW,sBAAsB;IACjC,uCAAuC;IACvC,eAAe,0BAA0B;IACzC,6DAA6D;IAC7D,SAAS,oBAAoB;IAC7B,uDAAuD;IACvD,cAAc,yBAAyB;IACvC,uDAAuD;IACvD,cAAc,yBAAyB;IACvC,2CAA2C;IAC3C,kBAAkB,6BAA6B;IAC/C,mDAAmD;IACnD,cAAc,yBAAyB;IACvC,2CAA2C;IAC3C,qBAAqB,gCAAgC;IACrD,+BAA+B;IAC/B,YAAY,uBAAuB;IACnC,wCAAwC;IACxC,gBAAgB,2BAA2B;IAC3C,iDAAiD;IACjD,YAAY,uBAAuB;IACnC,kDAAkD;IAClD,mBAAmB,8BAA8B;IACjD,8BAA8B;IAC9B,cAAc,yBAAyB;IACvC,mDAAmD;IACnD,cAAc,yBAAyB;IACvC,2CAA2C;IAC3C,qBAAqB,gCAAgC;IACrD,kCAAkC;IAClC,cAAc,yBAAyB;IACvC,mDAAmD;IACnD,cAAc,yBAAyB;IACvC,4CAA4C;IAC5C,qBAAqB,gCAAgC;IACrD,wCAAwC;IACxC,WAAW,sBAAsB;IACjC,gDAAgD;IAChD,WAAW,sBAAsB;IACjC,uCAAuC;IACvC,WAAW,qBAAqB;CACjC;AAED,oBAAY,UAAU;IACpB;;OAEG;IACH,IAAI,QAAQ;IACZ;;OAEG;IACH,MAAM,QAAQ;IACd;;OAEG;IACH,MAAM,QAAQ;CACf;AAED,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AACD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FontStyle = exports.FontWeight = exports.TextColor = exports.TextVariant = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Text component variants.
|
|
6
|
+
*/
|
|
7
|
+
var TextVariant;
|
|
8
|
+
(function (TextVariant) {
|
|
9
|
+
// Display Sizes
|
|
10
|
+
TextVariant["DisplayMd"] = "display-md";
|
|
11
|
+
// Heading Sizes
|
|
12
|
+
TextVariant["HeadingLg"] = "heading-lg";
|
|
13
|
+
TextVariant["HeadingMd"] = "heading-md";
|
|
14
|
+
TextVariant["HeadingSm"] = "heading-sm";
|
|
15
|
+
// Body Sizes
|
|
16
|
+
TextVariant["BodyLg"] = "body-lg";
|
|
17
|
+
TextVariant["BodyMd"] = "body-md";
|
|
18
|
+
TextVariant["BodySm"] = "body-sm";
|
|
19
|
+
TextVariant["BodyXs"] = "body-xs";
|
|
20
|
+
})(TextVariant || (exports.TextVariant = TextVariant = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Text colors
|
|
23
|
+
*/
|
|
24
|
+
var TextColor;
|
|
25
|
+
(function (TextColor) {
|
|
26
|
+
/** For default neutral text. */
|
|
27
|
+
TextColor["TextDefault"] = "text-text-default";
|
|
28
|
+
/** For softer contrast neutral text */
|
|
29
|
+
TextColor["TextAlternative"] = "text-text-alternative";
|
|
30
|
+
/** For the softest contrast neutral text (not accessible) */
|
|
31
|
+
TextColor["TextMuted"] = "text-text-muted";
|
|
32
|
+
/** For elements used on top of overlay/alternative. */
|
|
33
|
+
TextColor["OverlayInverse"] = "text-overlay-inverse";
|
|
34
|
+
/** For interactive, active, and selected semantics. */
|
|
35
|
+
TextColor["PrimaryDefault"] = "text-primary-default";
|
|
36
|
+
/** For softer variants of primary text. */
|
|
37
|
+
TextColor["PrimaryAlternative"] = "text-primary-alternative";
|
|
38
|
+
/** For elements used on top of primary/default. */
|
|
39
|
+
TextColor["PrimaryInverse"] = "text-primary-inverse";
|
|
40
|
+
/** For primary text in a pressed state. */
|
|
41
|
+
TextColor["PrimaryDefaultPressed"] = "text-primary-defaultPressed";
|
|
42
|
+
/** For critical alert text. */
|
|
43
|
+
TextColor["ErrorDefault"] = "text-error-default";
|
|
44
|
+
/** For stronger contrast error text. */
|
|
45
|
+
TextColor["ErrorAlternative"] = "text-error-alternative";
|
|
46
|
+
/** For elements used on top of error/default. */
|
|
47
|
+
TextColor["ErrorInverse"] = "text-error-inverse";
|
|
48
|
+
/** For critical alert text in a pressed state. */
|
|
49
|
+
TextColor["ErrorDefaultPressed"] = "text-error-defaultPressed";
|
|
50
|
+
/** For caution alert text. */
|
|
51
|
+
TextColor["WarningDefault"] = "text-warning-default";
|
|
52
|
+
/** For elements used on top of warning/default. */
|
|
53
|
+
TextColor["WarningInverse"] = "text-warning-inverse";
|
|
54
|
+
/** For caution text in a pressed state. */
|
|
55
|
+
TextColor["WarningDefaultPressed"] = "text-warning-defaultPressed";
|
|
56
|
+
/** For positive semantic text. */
|
|
57
|
+
TextColor["SuccessDefault"] = "text-success-default";
|
|
58
|
+
/** For elements used on top of success/default. */
|
|
59
|
+
TextColor["SuccessInverse"] = "text-success-inverse";
|
|
60
|
+
/** For positive text in a pressed state. */
|
|
61
|
+
TextColor["SuccessDefaultPressed"] = "text-success-defaultPressed";
|
|
62
|
+
/** For informational read-only text. */
|
|
63
|
+
TextColor["InfoDefault"] = "text-info-default";
|
|
64
|
+
/** For elements used on top of info/default. */
|
|
65
|
+
TextColor["InfoInverse"] = "text-info-inverse";
|
|
66
|
+
/** Make the text color transparent. */
|
|
67
|
+
TextColor["Transparent"] = "text-transparent";
|
|
68
|
+
})(TextColor || (exports.TextColor = TextColor = {}));
|
|
69
|
+
var FontWeight;
|
|
70
|
+
(function (FontWeight) {
|
|
71
|
+
/**
|
|
72
|
+
* Weight - 700
|
|
73
|
+
*/
|
|
74
|
+
FontWeight["Bold"] = "700";
|
|
75
|
+
/**
|
|
76
|
+
* Weight - 500
|
|
77
|
+
*/
|
|
78
|
+
FontWeight["Medium"] = "500";
|
|
79
|
+
/**
|
|
80
|
+
* Weight - 400
|
|
81
|
+
*/
|
|
82
|
+
FontWeight["Normal"] = "400";
|
|
83
|
+
})(FontWeight || (exports.FontWeight = FontWeight = {}));
|
|
84
|
+
var FontStyle;
|
|
85
|
+
(function (FontStyle) {
|
|
86
|
+
FontStyle["Italic"] = "italic";
|
|
87
|
+
FontStyle["Normal"] = "normal";
|
|
88
|
+
})(FontStyle || (exports.FontStyle = FontStyle = {}));
|
|
89
|
+
//# sourceMappingURL=Text.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.types.js","sourceRoot":"","sources":["../../../src/components/Text/Text.types.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,WAcX;AAdD,WAAY,WAAW;IACrB,gBAAgB;IAChB,uCAAwB,CAAA;IAExB,gBAAgB;IAChB,uCAAwB,CAAA;IACxB,uCAAwB,CAAA;IACxB,uCAAwB,CAAA;IAExB,aAAa;IACb,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;AACpB,CAAC,EAdW,WAAW,2BAAX,WAAW,QActB;AAED;;GAEG;AACH,IAAY,SA2CX;AA3CD,WAAY,SAAS;IACnB,gCAAgC;IAChC,8CAAiC,CAAA;IACjC,uCAAuC;IACvC,sDAAyC,CAAA;IACzC,6DAA6D;IAC7D,0CAA6B,CAAA;IAC7B,uDAAuD;IACvD,oDAAuC,CAAA;IACvC,uDAAuD;IACvD,oDAAuC,CAAA;IACvC,2CAA2C;IAC3C,4DAA+C,CAAA;IAC/C,mDAAmD;IACnD,oDAAuC,CAAA;IACvC,2CAA2C;IAC3C,kEAAqD,CAAA;IACrD,+BAA+B;IAC/B,gDAAmC,CAAA;IACnC,wCAAwC;IACxC,wDAA2C,CAAA;IAC3C,iDAAiD;IACjD,gDAAmC,CAAA;IACnC,kDAAkD;IAClD,8DAAiD,CAAA;IACjD,8BAA8B;IAC9B,oDAAuC,CAAA;IACvC,mDAAmD;IACnD,oDAAuC,CAAA;IACvC,2CAA2C;IAC3C,kEAAqD,CAAA;IACrD,kCAAkC;IAClC,oDAAuC,CAAA;IACvC,mDAAmD;IACnD,oDAAuC,CAAA;IACvC,4CAA4C;IAC5C,kEAAqD,CAAA;IACrD,wCAAwC;IACxC,8CAAiC,CAAA;IACjC,gDAAgD;IAChD,8CAAiC,CAAA;IACjC,uCAAuC;IACvC,6CAAgC,CAAA;AAClC,CAAC,EA3CW,SAAS,yBAAT,SAAS,QA2CpB;AAED,IAAY,UAaX;AAbD,WAAY,UAAU;IACpB;;OAEG;IACH,0BAAY,CAAA;IACZ;;OAEG;IACH,4BAAc,CAAA;IACd;;OAEG;IACH,4BAAc,CAAA;AAChB,CAAC,EAbW,UAAU,0BAAV,UAAU,QAarB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACnB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB","sourcesContent":["/* eslint-disable @typescript-eslint/no-shadow */\n// Third party dependencies.\nimport type { TextProps as RNTextProps } from 'react-native';\n\n/**\n * Text component variants.\n */\nexport enum TextVariant {\n // Display Sizes\n DisplayMd = 'display-md',\n\n // Heading Sizes\n HeadingLg = 'heading-lg',\n HeadingMd = 'heading-md',\n HeadingSm = 'heading-sm',\n\n // Body Sizes\n BodyLg = 'body-lg',\n BodyMd = 'body-md',\n BodySm = 'body-sm',\n BodyXs = 'body-xs',\n}\n\n/**\n * Text colors\n */\nexport enum TextColor {\n /** For default neutral text. */\n TextDefault = 'text-text-default',\n /** For softer contrast neutral text */\n TextAlternative = 'text-text-alternative',\n /** For the softest contrast neutral text (not accessible) */\n TextMuted = 'text-text-muted',\n /** For elements used on top of overlay/alternative. */\n OverlayInverse = 'text-overlay-inverse',\n /** For interactive, active, and selected semantics. */\n PrimaryDefault = 'text-primary-default',\n /** For softer variants of primary text. */\n PrimaryAlternative = 'text-primary-alternative',\n /** For elements used on top of primary/default. */\n PrimaryInverse = 'text-primary-inverse',\n /** For primary text in a pressed state. */\n PrimaryDefaultPressed = 'text-primary-defaultPressed',\n /** For critical alert text. */\n ErrorDefault = 'text-error-default',\n /** For stronger contrast error text. */\n ErrorAlternative = 'text-error-alternative',\n /** For elements used on top of error/default. */\n ErrorInverse = 'text-error-inverse',\n /** For critical alert text in a pressed state. */\n ErrorDefaultPressed = 'text-error-defaultPressed',\n /** For caution alert text. */\n WarningDefault = 'text-warning-default',\n /** For elements used on top of warning/default. */\n WarningInverse = 'text-warning-inverse',\n /** For caution text in a pressed state. */\n WarningDefaultPressed = 'text-warning-defaultPressed',\n /** For positive semantic text. */\n SuccessDefault = 'text-success-default',\n /** For elements used on top of success/default. */\n SuccessInverse = 'text-success-inverse',\n /** For positive text in a pressed state. */\n SuccessDefaultPressed = 'text-success-defaultPressed',\n /** For informational read-only text. */\n InfoDefault = 'text-info-default',\n /** For elements used on top of info/default. */\n InfoInverse = 'text-info-inverse',\n /** Make the text color transparent. */\n Transparent = 'text-transparent',\n}\n\nexport enum FontWeight {\n /**\n * Weight - 700\n */\n Bold = '700',\n /**\n * Weight - 500\n */\n Medium = '500',\n /**\n * Weight - 400\n */\n Normal = '400',\n}\n\nexport enum FontStyle {\n Italic = 'italic',\n Normal = 'normal',\n}\n/**\n * Text component props.\n */\nexport type TextProps = {\n /**\n * Optional enum to select between Typography variants.\n * @default BodyMD\n */\n variant?: TextVariant;\n /**\n * Text to be displayed.\n */\n children: React.ReactNode;\n /**\n * Optional prop to add color to text.\n */\n color?: TextColor;\n /**\n * Optional prop to adjust the weight of the font.\n */\n fontWeight?: FontWeight;\n /**\n * Optional prop to adjust the style of the font.\n */\n fontStyle?: FontStyle;\n /**\n * Optional prop to add twrnc overriding classNames.\n */\n twClassName?: string;\n} & RNTextProps;\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TextProps } from './Text.types';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a combined string of Tailwind CSS class names for the Text component
|
|
4
|
+
* based on the provided props. This utility simplifies the process of combining
|
|
5
|
+
* typography, color, font weight, and style classes, ensuring consistency with the
|
|
6
|
+
* design system.
|
|
7
|
+
*
|
|
8
|
+
* @param variant - Specifies the typography variant (e.g., body, heading, display).
|
|
9
|
+
* @param color - Specifies the text color based on the design system's color tokens.
|
|
10
|
+
* @param fontWeight - Specifies the font weight (e.g., normal, bold).
|
|
11
|
+
* @param fontStyle - Specifies the font style (e.g., normal, italic).
|
|
12
|
+
* @param twClassName - Additional custom Tailwind class names to be appended to the generated classes.
|
|
13
|
+
* @returns A string of combined Tailwind CSS class names.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* ```
|
|
17
|
+
* const classNames = generateTextClassNames({
|
|
18
|
+
* variant: TextVariant.BodyMd,
|
|
19
|
+
* color: TextColor.PrimaryDefault,
|
|
20
|
+
* fontWeight: FontWeight.Bold,
|
|
21
|
+
* fontStyle: FontStyle.Italic,
|
|
22
|
+
* twClassName: 'text-center underline',
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* console.log(classNames);
|
|
26
|
+
* // Output: "text-body-md font-body-md-bold-italic text-primary-default text-center underline"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const generateTextClassNames: ({ variant, color, fontWeight, fontStyle, twClassName, }: Partial<TextProps>) => string;
|
|
30
|
+
//# sourceMappingURL=Text.utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.utilities.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.utilities.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,sBAAsB,4DAMhC,QAAQ,SAAS,CAAC,KAAG,MAavB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateTextClassNames = void 0;
|
|
4
|
+
/* eslint-disable jsdoc/check-param-names */
|
|
5
|
+
/* eslint-disable jsdoc/require-param */
|
|
6
|
+
const Text_constants_1 = require("./Text.constants");
|
|
7
|
+
const Text_types_1 = require("./Text.types");
|
|
8
|
+
/**
|
|
9
|
+
* Generates a combined string of Tailwind CSS class names for the Text component
|
|
10
|
+
* based on the provided props. This utility simplifies the process of combining
|
|
11
|
+
* typography, color, font weight, and style classes, ensuring consistency with the
|
|
12
|
+
* design system.
|
|
13
|
+
*
|
|
14
|
+
* @param variant - Specifies the typography variant (e.g., body, heading, display).
|
|
15
|
+
* @param color - Specifies the text color based on the design system's color tokens.
|
|
16
|
+
* @param fontWeight - Specifies the font weight (e.g., normal, bold).
|
|
17
|
+
* @param fontStyle - Specifies the font style (e.g., normal, italic).
|
|
18
|
+
* @param twClassName - Additional custom Tailwind class names to be appended to the generated classes.
|
|
19
|
+
* @returns A string of combined Tailwind CSS class names.
|
|
20
|
+
*
|
|
21
|
+
* Example:
|
|
22
|
+
* ```
|
|
23
|
+
* const classNames = generateTextClassNames({
|
|
24
|
+
* variant: TextVariant.BodyMd,
|
|
25
|
+
* color: TextColor.PrimaryDefault,
|
|
26
|
+
* fontWeight: FontWeight.Bold,
|
|
27
|
+
* fontStyle: FontStyle.Italic,
|
|
28
|
+
* twClassName: 'text-center underline',
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* console.log(classNames);
|
|
32
|
+
* // Output: "text-body-md font-body-md-bold-italic text-primary-default text-center underline"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
const generateTextClassNames = ({ variant = Text_constants_1.DEFAULT_TEXT_VARIANT, color = Text_constants_1.DEFAULT_TEXT_COLOR, fontWeight = Text_types_1.FontWeight.Normal, fontStyle = Text_types_1.FontStyle.Normal, twClassName = '', }) => {
|
|
36
|
+
const fontWeightStyleClassname = Text_constants_1.MAPPING_FONTWEIGHT_TO_FONTFAMILYSTYLECLASSNAME[fontWeight];
|
|
37
|
+
const isItalic = fontStyle === Text_types_1.FontStyle.Italic;
|
|
38
|
+
const textClassname = `text-${variant}`;
|
|
39
|
+
const fontFamilyClassname = `font-${variant}${fontWeightStyleClassname}${isItalic ? '-italic' : ''}`;
|
|
40
|
+
const textColorClassname = `${color}`;
|
|
41
|
+
const mergedClassnames = `${textClassname} ${fontFamilyClassname} ${textColorClassname} ${twClassName}`.trim();
|
|
42
|
+
return mergedClassnames;
|
|
43
|
+
};
|
|
44
|
+
exports.generateTextClassNames = generateTextClassNames;
|
|
45
|
+
//# sourceMappingURL=Text.utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.utilities.js","sourceRoot":"","sources":["../../../src/components/Text/Text.utilities.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,wCAAwC;AACxC,qDAI0B;AAE1B,6CAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACI,MAAM,sBAAsB,GAAG,CAAC,EACrC,OAAO,GAAG,qCAAoB,EAC9B,KAAK,GAAG,mCAAkB,EAC1B,UAAU,GAAG,uBAAU,CAAC,MAAM,EAC9B,SAAS,GAAG,sBAAS,CAAC,MAAM,EAC5B,WAAW,GAAG,EAAE,GACG,EAAU,EAAE;IAC/B,MAAM,wBAAwB,GAC5B,+DAA8C,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,SAAS,KAAK,sBAAS,CAAC,MAAM,CAAC;IAChD,MAAM,aAAa,GAAG,QAAQ,OAAO,EAAE,CAAC;IACxC,MAAM,mBAAmB,GAAG,QAAQ,OAAO,GAAG,wBAAwB,GACpE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACzB,EAAE,CAAC;IACH,MAAM,kBAAkB,GAAG,GAAG,KAAK,EAAE,CAAC;IACtC,MAAM,gBAAgB,GACpB,GAAG,aAAa,IAAI,mBAAmB,IAAI,kBAAkB,IAAI,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAExF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAnBW,QAAA,sBAAsB,0BAmBjC","sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n/* eslint-disable jsdoc/require-param */\nimport {\n DEFAULT_TEXT_COLOR,\n DEFAULT_TEXT_VARIANT,\n MAPPING_FONTWEIGHT_TO_FONTFAMILYSTYLECLASSNAME,\n} from './Text.constants';\nimport type { TextProps } from './Text.types';\nimport { FontWeight, FontStyle } from './Text.types';\n\n/**\n * Generates a combined string of Tailwind CSS class names for the Text component\n * based on the provided props. This utility simplifies the process of combining\n * typography, color, font weight, and style classes, ensuring consistency with the\n * design system.\n *\n * @param variant - Specifies the typography variant (e.g., body, heading, display).\n * @param color - Specifies the text color based on the design system's color tokens.\n * @param fontWeight - Specifies the font weight (e.g., normal, bold).\n * @param fontStyle - Specifies the font style (e.g., normal, italic).\n * @param twClassName - Additional custom Tailwind class names to be appended to the generated classes.\n * @returns A string of combined Tailwind CSS class names.\n *\n * Example:\n * ```\n * const classNames = generateTextClassNames({\n * variant: TextVariant.BodyMd,\n * color: TextColor.PrimaryDefault,\n * fontWeight: FontWeight.Bold,\n * fontStyle: FontStyle.Italic,\n * twClassName: 'text-center underline',\n * });\n *\n * console.log(classNames);\n * // Output: \"text-body-md font-body-md-bold-italic text-primary-default text-center underline\"\n * ```\n */\nexport const generateTextClassNames = ({\n variant = DEFAULT_TEXT_VARIANT,\n color = DEFAULT_TEXT_COLOR,\n fontWeight = FontWeight.Normal,\n fontStyle = FontStyle.Normal,\n twClassName = '',\n}: Partial<TextProps>): string => {\n const fontWeightStyleClassname =\n MAPPING_FONTWEIGHT_TO_FONTFAMILYSTYLECLASSNAME[fontWeight];\n const isItalic = fontStyle === FontStyle.Italic;\n const textClassname = `text-${variant}`;\n const fontFamilyClassname = `font-${variant}${fontWeightStyleClassname}${\n isItalic ? '-italic' : ''\n }`;\n const textColorClassname = `${color}`;\n const mergedClassnames =\n `${textClassname} ${fontFamilyClassname} ${textColorClassname} ${twClassName}`.trim();\n\n return mergedClassnames;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FontStyle = exports.FontWeight = exports.TextColor = exports.TextVariant = exports.default = void 0;
|
|
7
|
+
var Text_1 = require("./Text");
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Text_1).default; } });
|
|
9
|
+
var Text_types_1 = require("./Text.types");
|
|
10
|
+
Object.defineProperty(exports, "TextVariant", { enumerable: true, get: function () { return Text_types_1.TextVariant; } });
|
|
11
|
+
Object.defineProperty(exports, "TextColor", { enumerable: true, get: function () { return Text_types_1.TextColor; } });
|
|
12
|
+
Object.defineProperty(exports, "FontWeight", { enumerable: true, get: function () { return Text_types_1.FontWeight; } });
|
|
13
|
+
Object.defineProperty(exports, "FontStyle", { enumerable: true, get: function () { return Text_types_1.FontStyle; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Text/index.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AAAxB,gHAAA,OAAO,OAAA;AAEhB,2CAA6E;AAApE,yGAAA,WAAW,OAAA;AAAE,uGAAA,SAAS,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,uGAAA,SAAS,OAAA","sourcesContent":["export { default } from './Text';\nexport type { TextProps } from './Text.types';\nexport { TextVariant, TextColor, FontWeight, FontStyle } from './Text.types';\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { TextButtonProps } from './TextButton.types';
|
|
2
|
+
export declare const DEFAULT_TEXTBUTTON_PROPS: Required<Pick<TextButtonProps, 'textProps' | 'isLoading' | 'loadingText' | 'spinnerProps' | 'startIconProps' | 'endIconProps' | 'isDisabled' | 'isInverse'>>;
|
|
3
|
+
//# sourceMappingURL=TextButton.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.constants.d.ts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAC7C,IAAI,CACF,eAAe,EACb,WAAW,GACX,WAAW,GACX,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,YAAY,GACZ,WAAW,CACd,CAsBF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_TEXTBUTTON_PROPS = void 0;
|
|
4
|
+
const Icon_1 = require("../Icon");
|
|
5
|
+
const Text_1 = require("../Text");
|
|
6
|
+
// Defaults
|
|
7
|
+
exports.DEFAULT_TEXTBUTTON_PROPS = {
|
|
8
|
+
textProps: {
|
|
9
|
+
variant: Text_1.TextVariant.BodyMd,
|
|
10
|
+
fontWeight: Text_1.FontWeight.Medium,
|
|
11
|
+
color: Text_1.TextColor.PrimaryDefault,
|
|
12
|
+
},
|
|
13
|
+
isLoading: false,
|
|
14
|
+
loadingText: 'Loading',
|
|
15
|
+
spinnerProps: {
|
|
16
|
+
color: Icon_1.IconColor.IconDefault,
|
|
17
|
+
},
|
|
18
|
+
startIconProps: {
|
|
19
|
+
size: Icon_1.IconSize.Sm,
|
|
20
|
+
testID: 'start-icon',
|
|
21
|
+
},
|
|
22
|
+
endIconProps: {
|
|
23
|
+
size: Icon_1.IconSize.Sm,
|
|
24
|
+
testID: 'end-icon',
|
|
25
|
+
},
|
|
26
|
+
isDisabled: false,
|
|
27
|
+
isInverse: false,
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=TextButton.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.constants.js","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.constants.ts"],"names":[],"mappings":";;;AAAA,kCAA8C;AAC9C,kCAA6D;AAG7D,WAAW;AACE,QAAA,wBAAwB,GAYjC;IACF,SAAS,EAAE;QACT,OAAO,EAAE,kBAAW,CAAC,MAAM;QAC3B,UAAU,EAAE,iBAAU,CAAC,MAAM;QAC7B,KAAK,EAAE,gBAAS,CAAC,cAAc;KAChC;IACD,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,SAAS;IACtB,YAAY,EAAE;QACZ,KAAK,EAAE,gBAAS,CAAC,WAAW;KAC7B;IACD,cAAc,EAAE;QACd,IAAI,EAAE,eAAQ,CAAC,EAAE;QACjB,MAAM,EAAE,YAAY;KACrB;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,eAAQ,CAAC,EAAE;QACjB,MAAM,EAAE,UAAU;KACnB;IACD,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;CACjB,CAAC","sourcesContent":["import { IconSize, IconColor } from '../Icon';\nimport { TextColor, TextVariant, FontWeight } from '../Text';\nimport type { TextButtonProps } from './TextButton.types';\n\n// Defaults\nexport const DEFAULT_TEXTBUTTON_PROPS: Required<\n Pick<\n TextButtonProps,\n | 'textProps'\n | 'isLoading'\n | 'loadingText'\n | 'spinnerProps'\n | 'startIconProps'\n | 'endIconProps'\n | 'isDisabled'\n | 'isInverse'\n >\n> = {\n textProps: {\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.PrimaryDefault,\n },\n isLoading: false,\n loadingText: 'Loading',\n spinnerProps: {\n color: IconColor.IconDefault,\n },\n startIconProps: {\n size: IconSize.Sm,\n testID: 'start-icon',\n },\n endIconProps: {\n size: IconSize.Sm,\n testID: 'end-icon',\n },\n isDisabled: false,\n isInverse: false,\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TextButtonProps } from './TextButton.types';
|
|
3
|
+
declare const TextButton: ({ children, textProps, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isInverse, onPress, onPressIn, onPressOut, onLongPress, twClassName, accessibilityRole, accessibilityLabel, style, ...props }: TextButtonProps) => React.JSX.Element;
|
|
4
|
+
export default TextButton;
|
|
5
|
+
//# sourceMappingURL=TextButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.d.ts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAWjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAM1D,QAAA,MAAM,UAAU,mSAuBb,eAAe,sBAsMjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
|
|
30
|
+
const design_system_twrnc_preset_1 = require("@metamask-previews/design-system-twrnc-preset");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const react_native_1 = require("react-native");
|
|
33
|
+
const Spinner_1 = __importDefault(require("../../temp-components/Spinner"));
|
|
34
|
+
const Icon_1 = __importDefault(require("../Icon"));
|
|
35
|
+
const Text_1 = __importDefault(require("../Text/Text"));
|
|
36
|
+
const TextButton_constants_1 = require("./TextButton.constants");
|
|
37
|
+
const TextButton_utilities_1 = require("./TextButton.utilities");
|
|
38
|
+
const TextButton = ({ children, textProps, isLoading = TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled = TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.isDisabled, isInverse = TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.isInverse, onPress, onPressIn, onPressOut, onLongPress, twClassName, accessibilityRole, accessibilityLabel, style, ...props }) => {
|
|
39
|
+
const [isPressed, setIsPressed] = (0, react_1.useState)(false);
|
|
40
|
+
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
41
|
+
// Styling calculation for state changes
|
|
42
|
+
const twContainerClassNames = (0, react_1.useMemo)(() => {
|
|
43
|
+
return (0, TextButton_utilities_1.generateTextButtonContainerClassNames)({
|
|
44
|
+
isPressed,
|
|
45
|
+
isLoading,
|
|
46
|
+
isDisabled,
|
|
47
|
+
twClassName,
|
|
48
|
+
});
|
|
49
|
+
}, [isPressed, isLoading, isDisabled, twClassName]);
|
|
50
|
+
const twTextClassNames = (0, react_1.useMemo)(() => {
|
|
51
|
+
return (0, TextButton_utilities_1.generateTextButtonTextClassNames)({
|
|
52
|
+
isPressed,
|
|
53
|
+
isInverse,
|
|
54
|
+
isLoading,
|
|
55
|
+
});
|
|
56
|
+
}, [isPressed, isInverse, isLoading]);
|
|
57
|
+
// Merging default settings for Icons with passed in props
|
|
58
|
+
const finalStartIconProps = {
|
|
59
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.startIconProps,
|
|
60
|
+
...startIconProps,
|
|
61
|
+
twClassName: `${twTextClassNames} ${startIconProps?.twClassName ?? ''}`,
|
|
62
|
+
};
|
|
63
|
+
const finalStartIconName = startIconName ?? startIconProps?.name;
|
|
64
|
+
const finalEndIconProps = {
|
|
65
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.endIconProps,
|
|
66
|
+
...endIconProps,
|
|
67
|
+
twClassName: `${twTextClassNames} ${endIconProps?.twClassName ?? ''}`,
|
|
68
|
+
};
|
|
69
|
+
const finalEndIconName = endIconName ?? endIconProps?.name;
|
|
70
|
+
const finalTextProps = {
|
|
71
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.textProps,
|
|
72
|
+
...textProps,
|
|
73
|
+
twClassName: `${twTextClassNames} ${textProps?.twClassName ?? ''}`,
|
|
74
|
+
};
|
|
75
|
+
// Merging spinner settings for Icons with passed in props
|
|
76
|
+
const finalSpinnerProps = {
|
|
77
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.spinnerProps,
|
|
78
|
+
loadingText,
|
|
79
|
+
color: twTextClassNames,
|
|
80
|
+
loadingTextProps: {
|
|
81
|
+
twClassName: `${twTextClassNames} mt-[2.5px]`,
|
|
82
|
+
},
|
|
83
|
+
...spinnerProps,
|
|
84
|
+
};
|
|
85
|
+
const onPressHandler = (event) => {
|
|
86
|
+
if (!isDisabled && !isLoading) {
|
|
87
|
+
onPress?.(event);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const onPressInHandler = (event) => {
|
|
91
|
+
if (!isDisabled && !isLoading) {
|
|
92
|
+
setIsPressed(true);
|
|
93
|
+
onPressIn?.(event);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const onPressOutHandler = (event) => {
|
|
97
|
+
if (!isDisabled && !isLoading) {
|
|
98
|
+
setIsPressed(false);
|
|
99
|
+
onPressOut?.(event);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const onLongPressHandler = (event) => {
|
|
103
|
+
if (!isDisabled && !isLoading) {
|
|
104
|
+
onLongPress?.(event);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Design Requirements
|
|
109
|
+
* TextButton needs to be able to be placed inline with other Texts along with
|
|
110
|
+
* accompanying icons.
|
|
111
|
+
*
|
|
112
|
+
* Limitations
|
|
113
|
+
* React Native renders Texts and components nested inside Texts very differently.
|
|
114
|
+
* In order to fulfil design requirements
|
|
115
|
+
* - TextButton needs to be built using Text wrapping the component to ensure
|
|
116
|
+
* when placed in line with other Texts, it can be properly displayed inline
|
|
117
|
+
* with other Texts.
|
|
118
|
+
* - Due to React Native Texts calculating the layout of nested components
|
|
119
|
+
* differently, there needs to be a few styling hacks applied below
|
|
120
|
+
*/
|
|
121
|
+
// Get the line height of the text, which is also the height of the component
|
|
122
|
+
const finalVariant = textProps?.variant || TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.textProps.variant;
|
|
123
|
+
const { lineHeight } = tw `text-${finalVariant}`;
|
|
124
|
+
const componentHeight = Number(lineHeight);
|
|
125
|
+
// Due to React Native rendering Views slightly above Texts, any non-texts
|
|
126
|
+
// need to be moved down
|
|
127
|
+
const nonTextOffSet = 2.5;
|
|
128
|
+
// Get the final sizes of Icons to help with manual alignments
|
|
129
|
+
const finalStartIconSize = startIconProps?.size || TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.startIconProps.size;
|
|
130
|
+
const finalEndIconSize = endIconProps?.size || TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.endIconProps.size;
|
|
131
|
+
// Offsets to vertically center the Icon
|
|
132
|
+
const finalStartIconOffset = (Number(lineHeight) - Number(finalStartIconSize)) / 2;
|
|
133
|
+
const finalEndIconOffset = (Number(lineHeight) - Number(finalEndIconSize)) / 2;
|
|
134
|
+
/**
|
|
135
|
+
* Due to Texts restricting nested components to manipulating layout with
|
|
136
|
+
* margins/paddings, we needed to add Nested Views in order to properly add
|
|
137
|
+
* additional margins/paddings. However, this causes the Text component to
|
|
138
|
+
* somehow not include the Icons as part of the calculation for displaying
|
|
139
|
+
* a change in background color onPress. Because of that, we need to mimic
|
|
140
|
+
* the behavior on the Icon wrappers by baking the margins into the Icon
|
|
141
|
+
* wrappers in order to display the background change properly
|
|
142
|
+
*/
|
|
143
|
+
const marginsBetweenIconAndText = 4;
|
|
144
|
+
const startIconWrapperWidth = Number(finalStartIconSize) + marginsBetweenIconAndText;
|
|
145
|
+
const endIconWrapperWidth = Number(finalEndIconSize) + marginsBetweenIconAndText;
|
|
146
|
+
return (<Text_1.default>
|
|
147
|
+
{finalStartIconName && <Text_1.default style={tw `hidden`}> </Text_1.default>}
|
|
148
|
+
{isLoading && (<react_native_1.View style={tw `${twContainerClassNames}`}>
|
|
149
|
+
<Spinner_1.default {...finalSpinnerProps}/>
|
|
150
|
+
</react_native_1.View>)}
|
|
151
|
+
<Text_1.default onPress={onPressHandler} onPressIn={onPressInHandler} onPressOut={onPressOutHandler} onLongPress={onLongPressHandler} accessible accessibilityRole="button" accessibilityLabel={accessibilityLabel} style={[tw `${twContainerClassNames}`, style]} testID="text-button" suppressHighlighting {...props}>
|
|
152
|
+
{!isLoading && (<>
|
|
153
|
+
{finalStartIconName ? (
|
|
154
|
+
// This additional View is needed, otherwise things are rendered
|
|
155
|
+
// VERY funkily
|
|
156
|
+
<react_native_1.View style={tw `h-[${componentHeight}px]`}>
|
|
157
|
+
<react_native_1.View style={tw `
|
|
158
|
+
${twContainerClassNames}
|
|
159
|
+
items-start mt-[${nonTextOffSet}px]
|
|
160
|
+
pt-[${finalStartIconOffset}px]
|
|
161
|
+
h-[${componentHeight}px]
|
|
162
|
+
w-[${startIconWrapperWidth}px]
|
|
163
|
+
`}>
|
|
164
|
+
<Icon_1.default name={finalStartIconName} {...finalStartIconProps}/>
|
|
165
|
+
</react_native_1.View>
|
|
166
|
+
</react_native_1.View>) : (startAccessory)}
|
|
167
|
+
<Text_1.default {...finalTextProps}>{children}</Text_1.default>
|
|
168
|
+
{finalEndIconName ? (
|
|
169
|
+
// This additional View is needed, otherwise things are rendered
|
|
170
|
+
// VERY funkily
|
|
171
|
+
<react_native_1.View style={tw `h-[${componentHeight}px]`}>
|
|
172
|
+
<react_native_1.View style={tw `
|
|
173
|
+
${twContainerClassNames}
|
|
174
|
+
items-end
|
|
175
|
+
mt-[${nonTextOffSet}px]
|
|
176
|
+
pt-[${finalEndIconOffset}px]
|
|
177
|
+
h-[${componentHeight}px] w-[${endIconWrapperWidth}px]`}>
|
|
178
|
+
<Icon_1.default name={finalEndIconName} {...finalEndIconProps}/>
|
|
179
|
+
</react_native_1.View>
|
|
180
|
+
</react_native_1.View>) : (endAccessory)}
|
|
181
|
+
</>)}
|
|
182
|
+
</Text_1.default>
|
|
183
|
+
{finalEndIconName && <Text_1.default style={tw `hidden`}> </Text_1.default>}
|
|
184
|
+
</Text_1.default>);
|
|
185
|
+
};
|
|
186
|
+
exports.default = TextButton;
|
|
187
|
+
//# sourceMappingURL=TextButton.js.map
|