fluent-styles 1.0.0
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/README.md +77 -0
- package/lib/commonjs/assets/img/doctor.png +0 -0
- package/lib/commonjs/index.js +248 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package/badge/index.js +159 -0
- package/lib/commonjs/package/badge/index.js.map +1 -0
- package/lib/commonjs/package/button/index.js +96 -0
- package/lib/commonjs/package/button/index.js.map +1 -0
- package/lib/commonjs/package/card/index.js +32 -0
- package/lib/commonjs/package/card/index.js.map +1 -0
- package/lib/commonjs/package/checkBox/index.js +84 -0
- package/lib/commonjs/package/checkBox/index.js.map +1 -0
- package/lib/commonjs/package/cycle/index.js +28 -0
- package/lib/commonjs/package/cycle/index.js.map +1 -0
- package/lib/commonjs/package/dialog/index.js +192 -0
- package/lib/commonjs/package/dialog/index.js.map +1 -0
- package/lib/commonjs/package/dropdown/index.js +116 -0
- package/lib/commonjs/package/dropdown/index.js.map +1 -0
- package/lib/commonjs/package/form/index.js +184 -0
- package/lib/commonjs/package/form/index.js.map +1 -0
- package/lib/commonjs/package/header/index.js +89 -0
- package/lib/commonjs/package/header/index.js.map +1 -0
- package/lib/commonjs/package/image/index.js +123 -0
- package/lib/commonjs/package/image/index.js.map +1 -0
- package/lib/commonjs/package/radioButton/index.js +84 -0
- package/lib/commonjs/package/radioButton/index.js.map +1 -0
- package/lib/commonjs/package/safeAreaView/index.js +16 -0
- package/lib/commonjs/package/safeAreaView/index.js.map +1 -0
- package/lib/commonjs/package/scrollView/index.js +16 -0
- package/lib/commonjs/package/scrollView/index.js.map +1 -0
- package/lib/commonjs/package/separator/index.js +33 -0
- package/lib/commonjs/package/separator/index.js.map +1 -0
- package/lib/commonjs/package/spacer/index.js +18 -0
- package/lib/commonjs/package/spacer/index.js.map +1 -0
- package/lib/commonjs/package/spinner/index.js +43 -0
- package/lib/commonjs/package/spinner/index.js.map +1 -0
- package/lib/commonjs/package/stack/__test__/index.test.js +91 -0
- package/lib/commonjs/package/stack/__test__/index.test.js.map +1 -0
- package/lib/commonjs/package/stack/index.js +41 -0
- package/lib/commonjs/package/stack/index.js.map +1 -0
- package/lib/commonjs/package/styled/__test__/index.test.js +161 -0
- package/lib/commonjs/package/styled/__test__/index.test.js.map +1 -0
- package/lib/commonjs/package/styled/index.js +42 -0
- package/lib/commonjs/package/styled/index.js.map +1 -0
- package/lib/commonjs/package/switch/index.js +43 -0
- package/lib/commonjs/package/switch/index.js.map +1 -0
- package/lib/commonjs/package/text/index.js +73 -0
- package/lib/commonjs/package/text/index.js.map +1 -0
- package/lib/commonjs/package/theme.js +384 -0
- package/lib/commonjs/package/theme.js.map +1 -0
- package/lib/commonjs/package/utils/index.js +130 -0
- package/lib/commonjs/package/utils/index.js.map +1 -0
- package/lib/commonjs/styled.code-workspace +9 -0
- package/lib/module/assets/img/doctor.png +0 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package/badge/index.js +151 -0
- package/lib/module/package/badge/index.js.map +1 -0
- package/lib/module/package/button/index.js +89 -0
- package/lib/module/package/button/index.js.map +1 -0
- package/lib/module/package/card/index.js +25 -0
- package/lib/module/package/card/index.js.map +1 -0
- package/lib/module/package/checkBox/index.js +75 -0
- package/lib/module/package/checkBox/index.js.map +1 -0
- package/lib/module/package/cycle/index.js +21 -0
- package/lib/module/package/cycle/index.js.map +1 -0
- package/lib/module/package/dialog/index.js +182 -0
- package/lib/module/package/dialog/index.js.map +1 -0
- package/lib/module/package/dropdown/index.js +106 -0
- package/lib/module/package/dropdown/index.js.map +1 -0
- package/lib/module/package/form/index.js +176 -0
- package/lib/module/package/form/index.js.map +1 -0
- package/lib/module/package/header/index.js +83 -0
- package/lib/module/package/header/index.js.map +1 -0
- package/lib/module/package/image/index.js +115 -0
- package/lib/module/package/image/index.js.map +1 -0
- package/lib/module/package/radioButton/index.js +75 -0
- package/lib/module/package/radioButton/index.js.map +1 -0
- package/lib/module/package/safeAreaView/index.js +11 -0
- package/lib/module/package/safeAreaView/index.js.map +1 -0
- package/lib/module/package/scrollView/index.js +11 -0
- package/lib/module/package/scrollView/index.js.map +1 -0
- package/lib/module/package/separator/index.js +26 -0
- package/lib/module/package/separator/index.js.map +1 -0
- package/lib/module/package/spacer/index.js +11 -0
- package/lib/module/package/spacer/index.js.map +1 -0
- package/lib/module/package/spinner/index.js +36 -0
- package/lib/module/package/spinner/index.js.map +1 -0
- package/lib/module/package/stack/__test__/index.test.js +89 -0
- package/lib/module/package/stack/__test__/index.test.js.map +1 -0
- package/lib/module/package/stack/index.js +36 -0
- package/lib/module/package/stack/index.js.map +1 -0
- package/lib/module/package/styled/__test__/index.test.js +158 -0
- package/lib/module/package/styled/__test__/index.test.js.map +1 -0
- package/lib/module/package/styled/index.js +35 -0
- package/lib/module/package/styled/index.js.map +1 -0
- package/lib/module/package/switch/index.js +36 -0
- package/lib/module/package/switch/index.js.map +1 -0
- package/lib/module/package/text/index.js +68 -0
- package/lib/module/package/text/index.js.map +1 -0
- package/lib/module/package/theme.js +379 -0
- package/lib/module/package/theme.js.map +1 -0
- package/lib/module/package/utils/index.js +120 -0
- package/lib/module/package/utils/index.js.map +1 -0
- package/lib/module/styled.code-workspace +9 -0
- package/package.json +85 -0
- package/src/assets/img/doctor.png +0 -0
- package/src/index.js +23 -0
- package/src/package/badge/index.jsx +133 -0
- package/src/package/button/index.jsx +80 -0
- package/src/package/card/index.jsx +38 -0
- package/src/package/checkBox/index.jsx +80 -0
- package/src/package/cycle/index.jsx +23 -0
- package/src/package/dialog/index.jsx +214 -0
- package/src/package/dropdown/index.jsx +102 -0
- package/src/package/form/index.jsx +145 -0
- package/src/package/header/index.jsx +92 -0
- package/src/package/image/index.jsx +93 -0
- package/src/package/radioButton/index.jsx +81 -0
- package/src/package/safeAreaView/index.jsx +12 -0
- package/src/package/scrollView/index.jsx +12 -0
- package/src/package/separator/index.jsx +26 -0
- package/src/package/spacer/index.jsx +13 -0
- package/src/package/spinner/index.jsx +33 -0
- package/src/package/stack/__test__/index.test.js +68 -0
- package/src/package/stack/index.jsx +37 -0
- package/src/package/styled/__test__/index.test.js +132 -0
- package/src/package/styled/index.js +32 -0
- package/src/package/switch/index.jsx +33 -0
- package/src/package/text/index.jsx +61 -0
- package/src/package/theme.js +376 -0
- package/src/package/utils/index.js +108 -0
- package/src/styled.code-workspace +9 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ScrollView } from 'react-native';
|
|
2
|
+
import { styled } from '../styled';
|
|
3
|
+
const StyledScrollView = styled(ScrollView, {
|
|
4
|
+
variants: {
|
|
5
|
+
backgroundColor: color => ({
|
|
6
|
+
backgroundColor: color
|
|
7
|
+
})
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
export { StyledScrollView };
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ScrollView","styled","StyledScrollView","variants","backgroundColor","color"],"sources":["index.jsx"],"sourcesContent":["import { ScrollView } from 'react-native'\r\nimport { styled } from '../styled'\r\n\r\nconst StyledScrollView = styled(ScrollView, { \r\n variants: {\r\n backgroundColor: color => ({\r\n backgroundColor: color\r\n })\r\n }\r\n})\r\n\r\nexport { StyledScrollView }\r\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,MAAM,QAAQ,WAAW;AAElC,MAAMC,gBAAgB,GAAGD,MAAM,CAACD,UAAU,EAAE;EAC1CG,QAAQ,EAAE;IACRC,eAAe,EAAEC,KAAK,KAAK;MACzBD,eAAe,EAAEC;IACnB,CAAC;EACH;AACF,CAAC,CAAC;AAEF,SAASH,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { XStack } from '../stack';
|
|
4
|
+
import { theme } from '../theme';
|
|
5
|
+
const StyledSeparator = ({
|
|
6
|
+
left,
|
|
7
|
+
right,
|
|
8
|
+
line,
|
|
9
|
+
lineProps,
|
|
10
|
+
...rest
|
|
11
|
+
}) => {
|
|
12
|
+
if (line) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(XStack, _extends({
|
|
14
|
+
borderTopWidth: 1,
|
|
15
|
+
borderTopColor: theme.colors.gray[800]
|
|
16
|
+
}, lineProps));
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement(XStack, _extends({
|
|
19
|
+
justifyContent: "space-between",
|
|
20
|
+
paddingVertical: 8,
|
|
21
|
+
paddingHorizontal: 8,
|
|
22
|
+
alignItems: "center"
|
|
23
|
+
}, rest), left && /*#__PURE__*/React.createElement(React.Fragment, null, left), right && /*#__PURE__*/React.createElement(React.Fragment, null, right));
|
|
24
|
+
};
|
|
25
|
+
export { StyledSeparator };
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","XStack","theme","StyledSeparator","left","right","line","lineProps","rest","createElement","_extends","borderTopWidth","borderTopColor","colors","gray","justifyContent","paddingVertical","paddingHorizontal","alignItems","Fragment"],"sources":["index.jsx"],"sourcesContent":["import React from 'react'\r\nimport { XStack } from '../stack'\r\nimport { theme } from '../theme'\r\n\r\nconst StyledSeparator = ({ left, right, line, lineProps, ...rest }) => {\r\n if (line) {\r\n return <XStack borderTopWidth={1} borderTopColor={theme.colors.gray[800]} {...lineProps} />\r\n }\r\n\r\n return (\r\n <XStack justifyContent='space-between' paddingVertical={8} paddingHorizontal={8} alignItems='center' {...rest}>\r\n {\r\n left && (\r\n <>{left}</>\r\n )\r\n }\r\n {\r\n right && (\r\n <>{right}</>\r\n )\r\n }\r\n </XStack>\r\n )\r\n}\r\n\r\nexport { StyledSeparator }\r\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,KAAK,QAAQ,UAAU;AAEhC,MAAMC,eAAe,GAAGA,CAAC;EAAEC,IAAI;EAAEC,KAAK;EAAEC,IAAI;EAAEC,SAAS;EAAE,GAAGC;AAAK,CAAC,KAAK;EACnE,IAAIF,IAAI,EAAE;IACN,oBAAON,KAAA,CAAAS,aAAA,CAACR,MAAM,EAAAS,QAAA;MAACC,cAAc,EAAE,CAAE;MAACC,cAAc,EAAEV,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC,GAAG;IAAE,GAAKP,SAAS,CAAG,CAAC;EAC/F;EAEA,oBACIP,KAAA,CAAAS,aAAA,CAACR,MAAM,EAAAS,QAAA;IAACK,cAAc,EAAC,eAAe;IAACC,eAAe,EAAE,CAAE;IAACC,iBAAiB,EAAE,CAAE;IAACC,UAAU,EAAC;EAAQ,GAAKV,IAAI,GAErGJ,IAAI,iBACAJ,KAAA,CAAAS,aAAA,CAAAT,KAAA,CAAAmB,QAAA,QAAGf,IAAO,CACb,EAGDC,KAAK,iBACDL,KAAA,CAAAS,aAAA,CAAAT,KAAA,CAAAmB,QAAA,QAAGd,KAAQ,CAGf,CAAC;AAEjB,CAAC;AAED,SAASF,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { styled } from "../styled";
|
|
4
|
+
const Spacer = styled(View);
|
|
5
|
+
const StyledSpacer = ({
|
|
6
|
+
...rest
|
|
7
|
+
}) => {
|
|
8
|
+
return /*#__PURE__*/React.createElement(Spacer, rest);
|
|
9
|
+
};
|
|
10
|
+
export { StyledSpacer };
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","styled","Spacer","StyledSpacer","rest","createElement"],"sources":["index.jsx"],"sourcesContent":["import React from \"react\";\r\nimport { View } from \"react-native\";\r\nimport { styled } from \"../styled\";\r\n\r\nconst Spacer = styled(View)\r\n\r\nconst StyledSpacer = ({ ...rest }) => {\r\n return (\r\n <Spacer {...rest} />\r\n )\r\n}\r\n\r\nexport {StyledSpacer}"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,MAAM,QAAQ,WAAW;AAElC,MAAMC,MAAM,GAAGD,MAAM,CAACD,IAAI,CAAC;AAE3B,MAAMG,YAAY,GAAGA,CAAC;EAAE,GAAGC;AAAK,CAAC,KAAK;EAClC,oBACIL,KAAA,CAAAM,aAAA,CAACH,MAAM,EAAKE,IAAO,CAAC;AAE5B,CAAC;AAED,SAAQD,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ActivityIndicator, StyleSheet } from 'react-native';
|
|
4
|
+
import { styled } from '../styled';
|
|
5
|
+
import { theme } from '../theme';
|
|
6
|
+
const Spinner = styled(ActivityIndicator, {
|
|
7
|
+
base: {
|
|
8
|
+
color: theme.colors.gray[400]
|
|
9
|
+
},
|
|
10
|
+
variants: {
|
|
11
|
+
overlay: {
|
|
12
|
+
true: {
|
|
13
|
+
...StyleSheet.absoluteFillObject,
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
flex: 1
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const StyledSpinner = ({
|
|
24
|
+
size = 120,
|
|
25
|
+
color = theme.colors.gray[400],
|
|
26
|
+
overlay = true,
|
|
27
|
+
...rest
|
|
28
|
+
}) => {
|
|
29
|
+
return /*#__PURE__*/React.createElement(Spinner, _extends({
|
|
30
|
+
size: size,
|
|
31
|
+
overlay: overlay,
|
|
32
|
+
color: color
|
|
33
|
+
}, rest));
|
|
34
|
+
};
|
|
35
|
+
export { StyledSpinner };
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","ActivityIndicator","StyleSheet","styled","theme","Spinner","base","color","colors","gray","variants","overlay","true","absoluteFillObject","position","backgroundColor","justifyContent","alignItems","flex","StyledSpinner","size","rest","createElement","_extends"],"sources":["index.jsx"],"sourcesContent":["import React from 'react'\r\nimport { ActivityIndicator, StyleSheet } from 'react-native'\r\nimport { styled } from '../styled'\r\nimport { theme } from '../theme'\r\n\r\nconst Spinner = styled(ActivityIndicator, {\r\n base: {\r\n color: theme.colors.gray[400]\r\n },\r\n variants: {\r\n overlay: {\r\n true: {\r\n ...StyleSheet.absoluteFillObject,\r\n position: 'absolute',\r\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\r\n justifyContent: 'center',\r\n alignItems: 'center',\r\n flex: 1\r\n }\r\n }\r\n }\r\n})\r\n\r\nconst StyledSpinner = ({\r\n\tsize = 120,\r\n\tcolor = theme.colors.gray[400],\r\n\toverlay = true,\r\n\t...rest\r\n}) => {\r\n return <Spinner size={size} overlay={overlay} color={color} {...rest} />\r\n}\r\n\r\nexport { StyledSpinner }\r\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,cAAc;AAC5D,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,QAAQ,UAAU;AAEhC,MAAMC,OAAO,GAAGF,MAAM,CAACF,iBAAiB,EAAE;EACxCK,IAAI,EAAE;IACJC,KAAK,EAAEH,KAAK,CAACI,MAAM,CAACC,IAAI,CAAC,GAAG;EAC9B,CAAC;EACDC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,IAAI,EAAE;QACJ,GAAGV,UAAU,CAACW,kBAAkB;QAChCC,QAAQ,EAAE,UAAU;QACpBC,eAAe,EAAE,oBAAoB;QACrCC,cAAc,EAAE,QAAQ;QACxBC,UAAU,EAAE,QAAQ;QACpBC,IAAI,EAAE;MACR;IACF;EACF;AACF,CAAC,CAAC;AAEF,MAAMC,aAAa,GAAGA,CAAC;EACtBC,IAAI,GAAG,GAAG;EACVb,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAAC,GAAG,CAAC;EAC9BE,OAAO,GAAG,IAAI;EACd,GAAGU;AACJ,CAAC,KAAK;EACJ,oBAAOrB,KAAA,CAAAsB,aAAA,CAACjB,OAAO,EAAAkB,QAAA;IAACH,IAAI,EAAEA,IAAK;IAACT,OAAO,EAAEA,OAAQ;IAACJ,KAAK,EAAEA;EAAM,GAAKc,IAAI,CAAG,CAAC;AAC1E,CAAC;AAED,SAASF,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { expect, jest } from '@jest/globals';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { Stack, XStack, YStack } from '..';
|
|
4
|
+
import { palettes, theme } from '../../theme';
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
describe("Stack", () => {
|
|
7
|
+
it("Should render correctly with base style", () => {
|
|
8
|
+
const {
|
|
9
|
+
getByTestId
|
|
10
|
+
} = render( /*#__PURE__*/React.createElement(Stack, {
|
|
11
|
+
testID: "test-stack-id"
|
|
12
|
+
}));
|
|
13
|
+
const stack = getByTestId('test-stack-id');
|
|
14
|
+
expect(stack).toHaveStyle({
|
|
15
|
+
position: 'relative'
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
it("Should render correctly when transparent variant is set to true", () => {
|
|
19
|
+
const {
|
|
20
|
+
getByTestId
|
|
21
|
+
} = render( /*#__PURE__*/React.createElement(Stack, {
|
|
22
|
+
transparent: true,
|
|
23
|
+
testID: "test-stack-id"
|
|
24
|
+
}));
|
|
25
|
+
const stack = getByTestId('test-stack-id');
|
|
26
|
+
expect(stack).toHaveStyle({
|
|
27
|
+
position: 'relative',
|
|
28
|
+
backgroundColor: palettes.transparent
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it("XStack should render flexDirection to row correctly", () => {
|
|
32
|
+
const {
|
|
33
|
+
getByTestId
|
|
34
|
+
} = render( /*#__PURE__*/React.createElement(XStack, {
|
|
35
|
+
testID: "test-stack-id"
|
|
36
|
+
}));
|
|
37
|
+
const stack = getByTestId('test-stack-id');
|
|
38
|
+
expect(stack).toHaveStyle({
|
|
39
|
+
flexDirection: 'row'
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it("XStack should render correctly when transparent variant is set to true", () => {
|
|
43
|
+
const {
|
|
44
|
+
getByTestId
|
|
45
|
+
} = render( /*#__PURE__*/React.createElement(XStack, {
|
|
46
|
+
transparent: true,
|
|
47
|
+
testID: "test-stack-id"
|
|
48
|
+
}));
|
|
49
|
+
const stack = getByTestId('test-stack-id');
|
|
50
|
+
expect(stack).toHaveStyle({
|
|
51
|
+
position: 'relative',
|
|
52
|
+
backgroundColor: palettes.transparent
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
it("YStack should render flexDirection to column correctly", () => {
|
|
56
|
+
const {
|
|
57
|
+
getByTestId
|
|
58
|
+
} = render( /*#__PURE__*/React.createElement(YStack, {
|
|
59
|
+
testID: "test-stack-id"
|
|
60
|
+
}));
|
|
61
|
+
const stack = getByTestId('test-stack-id');
|
|
62
|
+
expect(stack).toHaveStyle({
|
|
63
|
+
flexDirection: 'column'
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it("Should render shadow on stack correctly when shadow variant is set to light on ios", () => {
|
|
67
|
+
jest.spyOn(Platform, 'select').mockImplementation(obj => obj.ios);
|
|
68
|
+
const {
|
|
69
|
+
getByTestId
|
|
70
|
+
} = render( /*#__PURE__*/React.createElement(Stack, {
|
|
71
|
+
shadow: "light",
|
|
72
|
+
transparent: true,
|
|
73
|
+
testID: "test-stack-id"
|
|
74
|
+
}));
|
|
75
|
+
const stack = getByTestId('test-stack-id');
|
|
76
|
+
expect(stack).toHaveStyle({
|
|
77
|
+
position: 'relative',
|
|
78
|
+
backgroundColor: palettes.transparent,
|
|
79
|
+
shadowColor: theme.colors.gray[900],
|
|
80
|
+
shadowOffset: {
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 1
|
|
83
|
+
},
|
|
84
|
+
shadowOpacity: 0.22,
|
|
85
|
+
shadowRadius: 2.22
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["expect","jest","render","Stack","XStack","YStack","palettes","theme","Platform","describe","it","getByTestId","React","createElement","testID","stack","toHaveStyle","position","transparent","backgroundColor","flexDirection","spyOn","mockImplementation","obj","ios","shadow","shadowColor","colors","gray","shadowOffset","width","height","shadowOpacity","shadowRadius"],"sources":["index.test.js"],"sourcesContent":["import { expect, jest } from '@jest/globals';\r\nimport { render } from '@testing-library/react-native'\r\nimport { Stack, XStack, YStack } from '..'\r\nimport { palettes, theme } from '../../theme';\r\nimport { Platform } from 'react-native';\r\n\r\ndescribe(\"Stack\", () => {\r\n it(\"Should render correctly with base style\", () => {\r\n const { getByTestId } = render(<Stack testID='test-stack-id' />)\r\n\r\n const stack = getByTestId('test-stack-id')\r\n expect(stack).toHaveStyle({\r\n position: 'relative'\r\n })\r\n })\r\n\r\n it(\"Should render correctly when transparent variant is set to true\", () => {\r\n const { getByTestId } = render(<Stack transparent testID='test-stack-id' />)\r\n\r\n const stack = getByTestId('test-stack-id')\r\n expect(stack).toHaveStyle({\r\n position: 'relative',\r\n backgroundColor: palettes.transparent\r\n })\r\n })\r\n\r\n it(\"XStack should render flexDirection to row correctly\", () => {\r\n const { getByTestId } = render(<XStack testID='test-stack-id' />)\r\n\r\n const stack = getByTestId('test-stack-id')\r\n expect(stack).toHaveStyle({\r\n flexDirection: 'row' \r\n })\r\n })\r\n it(\"XStack should render correctly when transparent variant is set to true\", () => {\r\n const { getByTestId } = render(<XStack transparent testID='test-stack-id' />)\r\n\r\n const stack = getByTestId('test-stack-id')\r\n expect(stack).toHaveStyle({\r\n position: 'relative',\r\n backgroundColor: palettes.transparent\r\n })\r\n })\r\n\r\n it(\"YStack should render flexDirection to column correctly\", () => {\r\n const { getByTestId } = render(<YStack testID='test-stack-id' />)\r\n\r\n const stack = getByTestId('test-stack-id')\r\n expect(stack).toHaveStyle({\r\n flexDirection: 'column'\r\n })\r\n })\r\n\r\n it(\"Should render shadow on stack correctly when shadow variant is set to light on ios\", () => {\r\n jest.spyOn(Platform, 'select').mockImplementation((obj)=>obj.ios)\r\n const { getByTestId } = render(<Stack shadow='light' transparent testID='test-stack-id' />)\r\n\r\n const stack = getByTestId('test-stack-id')\r\n expect(stack).toHaveStyle({\r\n position: 'relative',\r\n backgroundColor: palettes.transparent,\r\n shadowColor: theme.colors.gray[900],\r\n shadowOffset: { width: 0, height: 1 },\r\n shadowOpacity: 0.22,\r\n shadowRadius: 2.22,\r\n })\r\n })\r\n})"],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,eAAe;AAC5C,SAASC,MAAM,QAAQ,+BAA+B;AACtD,SAASC,KAAK,EAAEC,MAAM,EAAEC,MAAM,QAAQ,IAAI;AAC1C,SAASC,QAAQ,EAAEC,KAAK,QAAQ,aAAa;AAC7C,SAASC,QAAQ,QAAQ,cAAc;AAEvCC,QAAQ,CAAC,OAAO,EAAE,MAAM;EACpBC,EAAE,CAAC,yCAAyC,EAAE,MAAM;IAChD,MAAM;MAAEC;IAAY,CAAC,GAAGT,MAAM,eAACU,KAAA,CAAAC,aAAA,CAACV,KAA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Q,CAACY;IAC9B,CAAC,CAAC;EACN,CAAC,CAAC;EAEFR,EAAE,CAAC,wDAAwD,EAAE,MAAM;IAC/D,MAAM;MAAEC;IAAY,CAAC,GAAGT,MAAM,eAACU,KAAA,CAAAC,aAAA,CAACR,MAAM;MAACS,MAAM,EAAC;IAAe,CAAE,CAAC,CAAC;IAEjE,MAAMC,KAAK,GAAGJ,WAAW,CAAC,eAAe,CAAC;IAC1CX,MAAM,CAACe,KAAK,CAAC,CAACC,WAAW,CAAC;MACtBI,aAAa,EAAE;IACnB,CAAC,CAAC;EACN,CAAC,CAAC;EAEFV,EAAE,CAAC,oFAAoF,EAAE,MAAM;IAC3FT,IAAI,CAACoB,KAAK,CAACb,QAAQ,EAAE,QAAQ,CAAC,CAACc,kBAAkB,CAAEC,GAAG,IAAGA,GAAG,CAACC,GAAG,CAAC;IACjE,MAAM;MAAEb;IAAY,CAAC,GAAGT,MAAM,eAACU,KAAA,CAAAC,aAAA,CAACV,KAAK;MAACsB,MAAM,EAAC,OAAO;MAACP,WAAW;MAACJ,MAAM,EAAC;IAAe,CAAE,CAAC,CAAC;IAE3F,MAAMC,KAAK,GAAGJ,WAAW,CAAC,eAAe,CAAC;IAC1CX,MAAM,CAACe,KAAK,CAAC,CAACC,WAAW,CAAC;MACtBC,QAAQ,EAAE,UAAU;MACpBE,eAAe,EAAEb,QAAQ,CAACY,WAAW;MACrCQ,WAAW,EAAEnB,KAAK,CAACoB,MAAM,CAACC,IAAI,CAAC,GAAG,CAAC;MACnCC,YAAY,EAAE;QAAEC,KAAK,EAAE,CAAC;QAAEC,MAAM,EAAE;MAAE,CAAC;MACrCC,aAAa,EAAE,IAAI;MACnBC,YAAY,EAAE;IAClB,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { View } from "react-native";
|
|
2
|
+
import { styled } from "../styled";
|
|
3
|
+
import { theme } from "../theme";
|
|
4
|
+
const YStack = styled(View, {
|
|
5
|
+
base: {
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
position: 'relative'
|
|
8
|
+
},
|
|
9
|
+
variants: {
|
|
10
|
+
transparent: {
|
|
11
|
+
true: {
|
|
12
|
+
backgroundColor: theme.colors.transparent
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const XStack = styled(View, {
|
|
18
|
+
base: {
|
|
19
|
+
flexDirection: 'row',
|
|
20
|
+
position: 'relative'
|
|
21
|
+
},
|
|
22
|
+
variants: {
|
|
23
|
+
transparent: {
|
|
24
|
+
true: {
|
|
25
|
+
backgroundColor: theme.colors.transparent
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
position: {
|
|
30
|
+
true: {
|
|
31
|
+
position: 'absolute'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export { XStack, YStack };
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","styled","theme","YStack","base","flexDirection","position","variants","transparent","true","backgroundColor","colors","XStack"],"sources":["index.jsx"],"sourcesContent":["import { View } from \"react-native\";\r\nimport { styled } from \"../styled\";\r\nimport { theme } from \"../theme\";\r\n\r\nconst YStack = styled(View, {\r\n base: {\r\n flexDirection: 'column',\r\n position: 'relative' \r\n },\r\n variants: {\r\n transparent: {\r\n true: {\r\n backgroundColor: theme.colors.transparent,\r\n }\r\n }\r\n } \r\n})\r\nconst XStack = styled(View, {\r\n base: {\r\n flexDirection: 'row', \r\n position:'relative' \r\n },\r\n variants: {\r\n transparent: {\r\n true: {\r\n backgroundColor: theme.colors.transparent,\r\n }\r\n }\r\n },\r\n position: {\r\n true: {\r\n position: 'absolute'\r\n }\r\n },\r\n})\r\n\r\nexport { XStack, YStack }"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AACnC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,QAAQ,UAAU;AAEhC,MAAMC,MAAM,GAAGF,MAAM,CAACD,IAAI,EAAE;EACxBI,IAAI,EAAE;IACFC,aAAa,EAAE,QAAQ;IACvBC,QAAQ,EAAE;EACd,CAAC;EACDC,QAAQ,EAAE;IACNC,WAAW,EAAE;MACTC,IAAI,EAAE;QACFC,eAAe,EAAER,KAAK,CAACS,MAAM,CAACH;MAClC;IACJ;EACJ;AACJ,CAAC,CAAC;AACF,MAAMI,MAAM,GAAGX,MAAM,CAACD,IAAI,EAAE;EACxBI,IAAI,EAAE;IACFC,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAC;EACb,CAAC;EACDC,QAAQ,EAAE;IACNC,WAAW,EAAE;MACTC,IAAI,EAAE;QACFC,eAAe,EAAER,KAAK,CAACS,MAAM,CAACH;MAClC;IACJ;EACJ,CAAC;EACDF,QAAQ,EAAE;IACNG,IAAI,EAAE;MACFH,QAAQ,EAAE;IACd;EACJ;AACJ,CAAC,CAAC;AAEF,SAASM,MAAM,EAAET,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
import { expect } from '@jest/globals';
|
|
5
|
+
import { styled } from "..";
|
|
6
|
+
import { Text } from "react-native";
|
|
7
|
+
import { theme } from "../../theme";
|
|
8
|
+
const StyledText = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(Text, _extends({}, props, {
|
|
9
|
+
ref: ref
|
|
10
|
+
})));
|
|
11
|
+
describe("Fluent Styles", () => {
|
|
12
|
+
it("Base style should render correctly", () => {
|
|
13
|
+
const base = {
|
|
14
|
+
backgroundColor: theme.colors.gray[50],
|
|
15
|
+
paddingHorizontal: 20,
|
|
16
|
+
paddingVertical: 10
|
|
17
|
+
};
|
|
18
|
+
const Text = styled(StyledText, {
|
|
19
|
+
base,
|
|
20
|
+
variants: {}
|
|
21
|
+
});
|
|
22
|
+
const {
|
|
23
|
+
getByText
|
|
24
|
+
} = render( /*#__PURE__*/React.createElement(Text, null, "Hello"));
|
|
25
|
+
expect(getByText("Hello")).toHaveStyle({
|
|
26
|
+
backgroundColor: theme.colors.gray[50],
|
|
27
|
+
paddingHorizontal: 20,
|
|
28
|
+
paddingVertical: 10
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it("Variants style should render correctly", () => {
|
|
32
|
+
const variants = {
|
|
33
|
+
border: {
|
|
34
|
+
true: {
|
|
35
|
+
borderColor: theme.colors.gray[50],
|
|
36
|
+
borderWidth: 1,
|
|
37
|
+
borderRadius: 8
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const Text = styled(StyledText, {
|
|
42
|
+
base: {},
|
|
43
|
+
variants
|
|
44
|
+
});
|
|
45
|
+
const {
|
|
46
|
+
getByText
|
|
47
|
+
} = render( /*#__PURE__*/React.createElement(Text, {
|
|
48
|
+
border: true
|
|
49
|
+
}, "Hello"));
|
|
50
|
+
expect(getByText("Hello")).toHaveStyle({
|
|
51
|
+
borderColor: theme.colors.gray[50],
|
|
52
|
+
borderWidth: 1,
|
|
53
|
+
borderRadius: 8
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
it("Variants style should not render correctly when variant is not enable", () => {
|
|
57
|
+
const variants = {
|
|
58
|
+
border: {
|
|
59
|
+
true: {
|
|
60
|
+
borderColor: theme.colors.gray[50],
|
|
61
|
+
borderWidth: 1,
|
|
62
|
+
borderRadius: 8
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const Text = styled(StyledText, {
|
|
67
|
+
base: {},
|
|
68
|
+
variants
|
|
69
|
+
});
|
|
70
|
+
const {
|
|
71
|
+
getByText
|
|
72
|
+
} = render( /*#__PURE__*/React.createElement(Text, null, "Hello"));
|
|
73
|
+
expect(getByText("Hello")).not.toHaveStyle({
|
|
74
|
+
borderColor: theme.colors.gray[50],
|
|
75
|
+
borderWidth: 1,
|
|
76
|
+
borderRadius: 8
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it("Variants styles should render correctly with function variant", () => {
|
|
80
|
+
const variants = {
|
|
81
|
+
fontSize: size => ({
|
|
82
|
+
fontSize: size
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
const Text = styled(StyledText, {
|
|
86
|
+
base: {},
|
|
87
|
+
variants
|
|
88
|
+
});
|
|
89
|
+
const {
|
|
90
|
+
getByText
|
|
91
|
+
} = render( /*#__PURE__*/React.createElement(Text, {
|
|
92
|
+
fontSize: 24
|
|
93
|
+
}, "Hello"));
|
|
94
|
+
expect(getByText("Hello")).toHaveStyle({
|
|
95
|
+
fontSize: 24
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
it("Variants styles should render correctly with nested variant", () => {
|
|
99
|
+
const base = {
|
|
100
|
+
backgroundColor: theme.colors.blueGray[100]
|
|
101
|
+
};
|
|
102
|
+
const variants = {
|
|
103
|
+
fontsize: size => ({
|
|
104
|
+
fontSize: size
|
|
105
|
+
}),
|
|
106
|
+
color: theme.colors
|
|
107
|
+
};
|
|
108
|
+
const Text = styled(StyledText, {
|
|
109
|
+
base,
|
|
110
|
+
variants
|
|
111
|
+
});
|
|
112
|
+
const {
|
|
113
|
+
getByText
|
|
114
|
+
} = render( /*#__PURE__*/React.createElement(Text, {
|
|
115
|
+
fontsize: 24,
|
|
116
|
+
color: "gray.100"
|
|
117
|
+
}, "Hello"));
|
|
118
|
+
expect(getByText('Hello')).toHaveStyle({
|
|
119
|
+
fontSize: 24,
|
|
120
|
+
color: theme.colors.gray[100],
|
|
121
|
+
backgroundColor: theme.colors.blueGray[100]
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
it("Should render prop style correctly", () => {
|
|
125
|
+
const Text = styled(StyledText, {
|
|
126
|
+
base: {},
|
|
127
|
+
variants: {}
|
|
128
|
+
});
|
|
129
|
+
const {
|
|
130
|
+
getByText
|
|
131
|
+
} = render( /*#__PURE__*/React.createElement(Text, {
|
|
132
|
+
style: {
|
|
133
|
+
color: theme.colors.gray[100]
|
|
134
|
+
}
|
|
135
|
+
}, "Hello"));
|
|
136
|
+
expect(getByText('Hello')).toHaveStyle({
|
|
137
|
+
color: theme.colors.gray[100]
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
it("Should render forwardRef as expected", () => {
|
|
141
|
+
const Text = styled(StyledText, {
|
|
142
|
+
base: {
|
|
143
|
+
color: theme.colors.gray[200]
|
|
144
|
+
},
|
|
145
|
+
variants: {}
|
|
146
|
+
});
|
|
147
|
+
const ref = /*#__PURE__*/React.createRef();
|
|
148
|
+
const {
|
|
149
|
+
getByText
|
|
150
|
+
} = render( /*#__PURE__*/React.createElement(Text, {
|
|
151
|
+
ref: ref
|
|
152
|
+
}, "Hello"));
|
|
153
|
+
const helloText = getByText('Hello');
|
|
154
|
+
expect(helloText).toBeTruthy();
|
|
155
|
+
expect(ref.current).toBeTruthy();
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","render","expect","styled","Text","theme","StyledText","forwardRef","props","ref","createElement","_extends","describe","it","base","backgroundColor","colors","gray","paddingHorizontal","paddingVertical","variants","getByText","toHaveStyle","border","true","borderColor","borderWidth","borderRadius","not","fontSize","size","blueGray","fontsize","color","style","createRef","helloText","toBeTruthy","current"],"sources":["index.test.js"],"sourcesContent":["\r\nimport React from \"react\";\r\nimport { render } from \"@testing-library/react-native\";\r\nimport { expect } from '@jest/globals';\r\nimport {styled} from \"..\";\r\nimport { Text } from \"react-native\";\r\nimport { theme } from \"../../theme\";\r\n\r\nconst StyledText = React.forwardRef((props, ref) => <Text {...props} ref={ref} />)\r\ndescribe(\"Fluent Styles\", () => {\r\n\tit(\"Base style should render correctly\", () => {\r\n\t\tconst base = {\r\n\t\t\tbackgroundColor: theme.colors.gray[50],\r\n\t\t\tpaddingHorizontal: 20,\r\n\t\t\tpaddingVertical: 10\r\n\t\t}\r\n\t\tconst Text = styled(StyledText, { base, variants: {} });\r\n\t\tconst { getByText } = render(<Text>Hello</Text>)\r\n\r\n\t\texpect(getByText(\"Hello\")).toHaveStyle({\r\n\t\t\tbackgroundColor: theme.colors.gray[50],\r\n\t\t\tpaddingHorizontal: 20,\r\n\t\t\tpaddingVertical: 10\r\n\t\t})\r\n\t});\r\n\r\n\tit(\"Variants style should render correctly\", () => {\r\n\t\tconst variants = {\r\n\t\t\tborder: {\r\n\t\t\t\ttrue: {\r\n\t\t\t\t\tborderColor: theme.colors.gray[50],\r\n\t\t\t\t\tborderWidth: 1,\r\n\t\t\t\t\tborderRadius: 8\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst Text = styled(StyledText, { base: {}, variants });\r\n\t\tconst { getByText } = render(<Text border>Hello</Text>)\r\n\r\n\t\texpect(getByText(\"Hello\")).toHaveStyle({\r\n\t\t\tborderColor: theme.colors.gray[50],\r\n\t\t\tborderWidth: 1,\r\n\t\t\tborderRadius: 8\r\n\t\t})\r\n\t});\r\n\r\n\tit(\"Variants style should not render correctly when variant is not enable\", () => {\r\n\t\tconst variants = {\r\n\t\t\tborder: {\r\n\t\t\t\ttrue: {\r\n\t\t\t\t\tborderColor: theme.colors.gray[50],\r\n\t\t\t\t\tborderWidth: 1,\r\n\t\t\t\t\tborderRadius: 8\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst Text = styled(StyledText, { base: {}, variants });\r\n\t\tconst { getByText } = render(<Text>Hello</Text>)\r\n\r\n\t\texpect(getByText(\"Hello\")).not.toHaveStyle({\r\n\t\t\tborderColor: theme.colors.gray[50],\r\n\t\t\tborderWidth: 1,\r\n\t\t\tborderRadius: 8\r\n\t\t})\r\n\t});\r\n\r\n\tit(\"Variants styles should render correctly with function variant\", () => {\r\n\t\tconst variants = {\r\n\t\t\tfontSize: (size) => ({\r\n\t\t\t\tfontSize: size\r\n\t\t\t})\r\n\t\t}\r\n\t\tconst Text = styled(StyledText, { base: {}, variants });\r\n\t\tconst { getByText } = render(<Text fontSize={24}>Hello</Text>)\r\n\r\n\t\texpect(getByText(\"Hello\")).toHaveStyle({\r\n\t\t\tfontSize: 24\r\n\t\t})\r\n\t});\r\n\r\n\tit(\"Variants styles should render correctly with nested variant\", () => {\r\n\t\tconst base = {\r\n\t\t\tbackgroundColor: theme.colors.blueGray[100]\r\n\t\t};\r\n\t\tconst variants = {\r\n\t\t\tfontsize: (size) => ({\r\n\t\t\t\tfontSize: size\r\n\t\t\t}),\r\n\t\t\tcolor: theme.colors\r\n\t\t};\r\n\t\tconst Text = styled(StyledText, { base, variants });\r\n\t\tconst { getByText } = render(\r\n\t\t\t<Text fontsize={24} color=\"gray.100\">\r\n\t\t\t\tHello\r\n\t\t\t</Text>\r\n\t\t);\r\n\r\n\t\texpect(getByText('Hello')).toHaveStyle({\r\n\t\t\tfontSize: 24,\r\n\t\t\tcolor: theme.colors.gray[100],\r\n\t\t\tbackgroundColor: theme.colors.blueGray[100]\r\n\t\t});\r\n\t});\r\n\r\n\tit(\"Should render prop style correctly\", () => {\t\t\r\n\t\tconst Text = styled(StyledText, { base :{}, variants :{} });\r\n\t\tconst { getByText } = render(\r\n\t\t\t<Text style={{ color: theme.colors.gray[100] }}>\r\n\t\t\t\tHello\r\n\t\t\t</Text>\r\n\t\t);\r\n\r\n\t\texpect(getByText('Hello')).toHaveStyle({\t\t\t\r\n\t\t\tcolor: theme.colors.gray[100]\t\t\t\r\n\t\t});\r\n\t});\r\n\r\n\tit(\"Should render forwardRef as expected\", () => {\r\n\t\tconst Text = styled(StyledText, { base: { color: theme.colors.gray[200]}, variants: {} });\r\n\t\tconst ref = React.createRef()\r\n\t\tconst { getByText } = render(\r\n\t\t\t<Text ref={ref}>\r\n\t\t\t\tHello\r\n\t\t\t</Text>\r\n\t\t);\r\n\r\n\t\tconst helloText = getByText('Hello');\r\n\t\texpect(helloText).toBeTruthy();\r\n\t\texpect(ref.current).toBeTruthy();\t\t\r\n\t});\r\n\r\n});\r\n"],"mappings":";AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,+BAA+B;AACtD,SAASC,MAAM,QAAQ,eAAe;AACtC,SAAQC,MAAM,QAAO,IAAI;AACzB,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,KAAK,QAAQ,aAAa;AAEnC,MAAMC,UAAU,gBAAGN,KAAK,CAACO,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,kBAAKT,KAAA,CAAAU,aAAA,CAACN,IAAI,EAAAO,QAAA,KAAKH,KAAK;EAAEC,GAAG,EAAEA;AAAI,EAAE,CAAC,CAAC;AAClFG,QAAQ,CAAC,eAAe,EAAE,MAAM;EAC/BC,EAAE,CAAC,oCAAoC,EAAE,MAAM;IAC9C,MAAMC,IAAI,GAAG;MACZC,eAAe,EAAEV,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC,EAAE,CAAC;MACtCC,iBAAiB,EAAE,EAAE;MACrBC,eAAe,EAAE;IAClB,CAAC;IACD,MAAMf,IAAI,GAAGD,MAAM,CAACG,UAAU,EAAE;MAAEQ,IAAI;MAAEM,QAAQ,EAAE,CAAC;IAAE,CAAC,CAAC;IACvD,MAAM;MAAEC;IAAU,CAAC,GAAGpB,MAAM,eAACD,KAAA,CAAAU,aAAA,CAACN,IAAI,QAAC,OAAW,CAAC,CAAC;IAEhDF,MAAM,CAACmB,SAAS,CAAC,OAAO,CAAC,CAAC,CAACC,WAAW,CAAC;MACtCP,eAAe,EAAEV,KAAK,CAACW,MAAM,CAACC,IAAI,CAAC,EAAE,CAAC;MACtCC,iBAAiB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AC,OAEV,CACP,CAAC;IAED,MAAM2B,SAAS,GAAGf,SAAS,CAAC,OAAO,CAAC;IACpCnB,MAAM,CAACkC,SAAS,CAAC,CAACC,UAAU,CAAC,CAAC;IAC9BnC,MAAM,CAACO,GAAG,CAAC6B,OAAO,CAAC,CAACD,UAAU,CAAC,CAAC;EACjC,CAAC,CAAC;AAEH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
const styled = (Component, {
|
|
6
|
+
base,
|
|
7
|
+
variants
|
|
8
|
+
} = {}) => {
|
|
9
|
+
return /*#__PURE__*/forwardRef((props, ref) => {
|
|
10
|
+
const styles = {
|
|
11
|
+
...(base || {})
|
|
12
|
+
};
|
|
13
|
+
const options = props;
|
|
14
|
+
Object.keys(variants || {}).forEach(category => {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
const variantSelected = options[category];
|
|
17
|
+
const variantValue = variants[category];
|
|
18
|
+
if (typeof variantValue === "function") {
|
|
19
|
+
const style = variantValue(variantSelected, options);
|
|
20
|
+
if (style) {
|
|
21
|
+
Object.assign(styles, style);
|
|
22
|
+
}
|
|
23
|
+
} else if (variantValue && variantValue[variantSelected]) {
|
|
24
|
+
const value = variantValue[variantSelected];
|
|
25
|
+
Object.assign(styles, typeof value === "function" ? value(options) : value);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
29
|
+
style: styles,
|
|
30
|
+
ref: ref
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export { styled };
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","styled","Component","base","variants","props","ref","styles","options","Object","keys","forEach","category","variantSelected","variantValue","style","assign","value","createElement","_extends"],"sources":["index.js"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\n// @ts-ignore\nconst styled = (Component, { base, variants } = {}) => {\n return forwardRef((props, ref) => {\n const styles = { ...(base || {}) };\n const options = props;\n\n Object.keys(variants || {}).forEach((category) => {\n // @ts-ignore\n const variantSelected = options[category];\n const variantValue = variants[category];\n\n if (typeof variantValue === \"function\") {\n const style = variantValue(variantSelected, options);\n if (style) {\n Object.assign(styles, style);\n }\n } else if (variantValue && variantValue[variantSelected]) {\n const value = variantValue[variantSelected];\n Object.assign(\n styles,\n typeof value === \"function\" ? value(options) : value\n );\n }\n }); \n\n return <Component {...props} style={styles} ref={ref} />;\n });\n};\n\nexport { styled }\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;;AAEzC;AACA,MAAMC,MAAM,GAAGA,CAACC,SAAS,EAAE;EAAEC,IAAI;EAAEC;AAAS,CAAC,GAAG,CAAC,CAAC,KAAK;EACrD,oBAAOJ,UAAU,CAAC,CAACK,KAAK,EAAEC,GAAG,KAAK;IAChC,MAAMC,MAAM,GAAG;MAAE,IAAIJ,IAAI,IAAI,CAAC,CAAC;IAAE,CAAC;IAClC,MAAMK,OAAO,GAAGH,KAAK;IAErBI,MAAM,CAACC,IAAI,CAACN,QAAQ,IAAI,CAAC,CAAC,CAAC,CAACO,OAAO,CAAEC,QAAQ,IAAK;MAChD;MACA,MAAMC,eAAe,GAAGL,OAAO,CAACI,QAAQ,CAAC;MACzC,MAAME,YAAY,GAAGV,QAAQ,CAACQ,QAAQ,CAAC;MAEvC,IAAI,OAAOE,YAAY,KAAK,UAAU,EAAE;QACtC,MAAMC,KAAK,GAAGD,YAAY,CAACD,eAAe,EAAEL,OAAO,CAAC;QACpD,IAAIO,KAAK,EAAE;UACTN,MAAM,CAACO,MAAM,CAACT,MAAM,EAAEQ,KAAK,CAAC;QAC9B;MACF,CAAC,MAAM,IAAID,YAAY,IAAIA,YAAY,CAACD,eAAe,CAAC,EAAE;QACxD,MAAMI,KAAK,GAAGH,YAAY,CAACD,eAAe,CAAC;QAC3CJ,MAAM,CAACO,MAAM,CACXT,MAAM,EACN,OAAOU,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACT,OAAO,CAAC,GAAGS,KACjD,CAAC;MACH;IACF,CAAC,CAAC;IAEF,oBAAOlB,KAAA,CAAAmB,aAAA,CAAChB,SAAS,EAAAiB,QAAA,KAAKd,KAAK;MAAEU,KAAK,EAAER,MAAO;MAACD,GAAG,EAAEA;IAAI,EAAG,CAAC;EAC3D,CAAC,CAAC;AACJ,CAAC;AAED,SAASL,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Switch as SwitchSource } from 'react-native';
|
|
4
|
+
import { styled } from '../styled';
|
|
5
|
+
import { theme } from '../theme';
|
|
6
|
+
const Switch = styled(SwitchSource, {
|
|
7
|
+
base: {
|
|
8
|
+
transform: [{
|
|
9
|
+
scaleX: 2
|
|
10
|
+
}, {
|
|
11
|
+
scaleY: 2
|
|
12
|
+
}]
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const StyledSwitch = ({
|
|
16
|
+
trackColorOff = theme.colors.gray[400],
|
|
17
|
+
trackColorOn = theme.colors.green[500],
|
|
18
|
+
thumbColorOff = theme.colors.gray[400],
|
|
19
|
+
thumbColorOn = theme.colors.pink[500],
|
|
20
|
+
isEnabled,
|
|
21
|
+
onChange,
|
|
22
|
+
...rest
|
|
23
|
+
}) => {
|
|
24
|
+
return /*#__PURE__*/React.createElement(Switch, _extends({
|
|
25
|
+
trackColor: {
|
|
26
|
+
false: trackColorOff,
|
|
27
|
+
true: trackColorOn
|
|
28
|
+
},
|
|
29
|
+
thumbColor: isEnabled ? thumbColorOn : thumbColorOff,
|
|
30
|
+
ios_backgroundColor: theme.colors.gray[800],
|
|
31
|
+
onValueChange: onChange,
|
|
32
|
+
value: isEnabled
|
|
33
|
+
}, rest));
|
|
34
|
+
};
|
|
35
|
+
export { StyledSwitch };
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Switch","SwitchSource","styled","theme","base","transform","scaleX","scaleY","StyledSwitch","trackColorOff","colors","gray","trackColorOn","green","thumbColorOff","thumbColorOn","pink","isEnabled","onChange","rest","createElement","_extends","trackColor","false","true","thumbColor","ios_backgroundColor","onValueChange","value"],"sources":["index.jsx"],"sourcesContent":["import React from 'react'\r\nimport { Switch as SwitchSource } from 'react-native'\r\nimport { styled } from '../styled'\r\nimport { theme } from '../theme'\r\n\r\nconst Switch = styled(SwitchSource, {\r\n base: {\r\n transform: [{ scaleX: 2 }, { scaleY: 2 }]\r\n }\r\n})\r\n\r\nconst StyledSwitch = ({\r\n\ttrackColorOff = theme.colors.gray[400],\r\n\ttrackColorOn = theme.colors.green[500],\r\n\tthumbColorOff = theme.colors.gray[400],\r\n\tthumbColorOn = theme.colors.pink[500],\r\n\tisEnabled,\r\n\tonChange,\r\n\t...rest\r\n}) => {\r\n return (\r\n <Switch\r\n trackColor={{ false: trackColorOff, true: trackColorOn }}\r\n thumbColor={isEnabled ? thumbColorOn : thumbColorOff}\r\n ios_backgroundColor={theme.colors.gray[800]}\r\n onValueChange={onChange}\r\n value={isEnabled}\r\n {...rest}\r\n\t\t/>\r\n )\r\n}\r\n\r\nexport { StyledSwitch }\r\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,IAAIC,YAAY,QAAQ,cAAc;AACrD,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,QAAQ,UAAU;AAEhC,MAAMH,MAAM,GAAGE,MAAM,CAACD,YAAY,EAAE;EAClCG,IAAI,EAAE;IACJC,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC,EAAE;MAAEC,MAAM,EAAE;IAAE,CAAC;EAC1C;AACF,CAAC,CAAC;AAEF,MAAMC,YAAY,GAAGA,CAAC;EACrBC,aAAa,GAAGN,KAAK,CAACO,MAAM,CAACC,IAAI,CAAC,GAAG,CAAC;EACtCC,YAAY,GAAGT,KAAK,CAACO,MAAM,CAACG,KAAK,CAAC,GAAG,CAAC;EACtCC,aAAa,GAAGX,KAAK,CAACO,MAAM,CAACC,IAAI,CAAC,GAAG,CAAC;EACtCI,YAAY,GAAGZ,KAAK,CAACO,MAAM,CAACM,IAAI,CAAC,GAAG,CAAC;EACrCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AACJ,CAAC,KAAK;EACJ,oBACEpB,KAAA,CAAAqB,aAAA,CAACpB,MAAM,EAAAqB,QAAA;IACLC,UAAU,EAAE;MAAEC,KAAK,EAAEd,aAAa;MAAEe,IAAI,EAAEZ;IAAa,CAAE;IACzDa,UAAU,EAAER,SAAS,GAAGF,YAAY,GAAGD,aAAc;IACrDY,mBAAmB,EAAEvB,KAAK,CAACO,MAAM,CAACC,IAAI,CAAC,GAAG,CAAE;IAC5CgB,aAAa,EAAET,QAAS;IACxBU,KAAK,EAAEX;EAAU,GACbE,IAAI,CACX,CAAC;AAEJ,CAAC;AAED,SAASX,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Text } from 'react-native';
|
|
2
|
+
import { styled } from '../styled';
|
|
3
|
+
import { theme } from '../theme';
|
|
4
|
+
import { isValidColor, isValidNumber, isValidString } from '../utils';
|
|
5
|
+
const StyledText = styled(Text, {
|
|
6
|
+
base: {
|
|
7
|
+
fontSize: theme.fontSize.normal,
|
|
8
|
+
color: theme.colors.gray[800],
|
|
9
|
+
fontWeight: theme.fontWeight.normal
|
|
10
|
+
},
|
|
11
|
+
variants: {
|
|
12
|
+
fontWeight: (size = theme.fontWeight.normal) => {
|
|
13
|
+
if (!isValidString(size)) {
|
|
14
|
+
throw new Error('Invalid fontWeight value');
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
fontWeight: size
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
color: (color = theme.colors.gray[800]) => {
|
|
21
|
+
if (!isValidColor(color)) {
|
|
22
|
+
throw new Error('Invalid color value');
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
color: color
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
fontSize: (size = theme.fontSize.normal) => {
|
|
29
|
+
if (!isValidNumber(size)) {
|
|
30
|
+
throw new Error('Invalid fontSize value');
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
fontSize: size
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
textDecorationLine: {
|
|
37
|
+
true: {
|
|
38
|
+
textDecorationLine: 'underline'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
flexWrap: 'wrap',
|
|
42
|
+
selected: {
|
|
43
|
+
true: {
|
|
44
|
+
color: theme.colors.gray[1]
|
|
45
|
+
},
|
|
46
|
+
false: {
|
|
47
|
+
color: theme.colors.gray[800]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
fontFamily: font => {
|
|
51
|
+
if (!font) return;
|
|
52
|
+
return {
|
|
53
|
+
fontFamily: font
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
textAlign: (align = 'left') => {
|
|
57
|
+
const validAlignments = ['auto', 'left', 'right', 'center', 'justify'];
|
|
58
|
+
if (!validAlignments.includes(align)) {
|
|
59
|
+
throw new Error('Invalid textAlign value');
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
textAlign: align
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export { StyledText };
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Text","styled","theme","isValidColor","isValidNumber","isValidString","StyledText","base","fontSize","normal","color","colors","gray","fontWeight","variants","size","Error","textDecorationLine","true","flexWrap","selected","false","fontFamily","font","textAlign","align","validAlignments","includes"],"sources":["index.jsx"],"sourcesContent":["import { Text } from 'react-native'\r\nimport { styled } from '../styled'\r\nimport { theme } from '../theme'\r\nimport { isValidColor, isValidNumber, isValidString } from '../utils'\r\n\r\nconst StyledText = styled(Text, {\r\n base: {\r\n fontSize: theme.fontSize.normal,\r\n color: theme.colors.gray[800],\r\n fontWeight: theme.fontWeight.normal\r\n },\r\n variants: {\r\n fontWeight: (size = theme.fontWeight.normal) => {\r\n if (!isValidString(size)) {\r\n throw new Error('Invalid fontWeight value')\r\n }\r\n return { fontWeight: size }\r\n },\r\n color: (color = theme.colors.gray[800]) => {\r\n if (!isValidColor(color)) {\r\n throw new Error('Invalid color value')\r\n }\r\n return { color: color }\r\n },\r\n fontSize: (size = theme.fontSize.normal) => {\r\n if (!isValidNumber(size)) {\r\n throw new Error('Invalid fontSize value')\r\n }\r\n return { fontSize: size }\r\n },\r\n textDecorationLine: {\r\n true: {\r\n textDecorationLine: 'underline'\r\n }\r\n },\r\n flexWrap: 'wrap',\r\n selected: {\r\n true: {\r\n color: theme.colors.gray[1]\r\n },\r\n false: {\r\n color: theme.colors.gray[800]\r\n }\r\n },\r\n fontFamily: font => {\r\n if (!font) return\r\n return {\r\n fontFamily: font\r\n }\r\n },\r\n textAlign: (align = 'left') => {\r\n const validAlignments = ['auto', 'left', 'right', 'center', 'justify']\r\n if (!validAlignments.includes(align)) {\r\n throw new Error('Invalid textAlign value')\r\n }\r\n return { textAlign: align }\r\n }\r\n }\r\n})\r\n\r\nexport { StyledText }\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