@mobilestock-native/button 0.0.3 → 0.0.5
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/index.d.ts +11 -0
- package/index.js +17 -0
- package/package.json +6 -13
- package/src/index.tsx +0 -47
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { TouchableHighlightProps, StyleProp, TextStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface PropsButton extends TouchableHighlightProps {
|
|
5
|
+
text?: string;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
textStyle?: StyleProp<TextStyle>;
|
|
8
|
+
}
|
|
9
|
+
declare function Button(props: PropsButton): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { type PropsButton, Button as default };
|
package/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";var f=Object.create;var r=Object.defineProperty,T=Object.defineProperties,b=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertyNames,s=Object.getOwnPropertySymbols,$=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;var a=(t,e,o)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,x=(t,e)=>{for(var o in e||(e={}))u.call(e,o)&&a(t,o,e[o]);if(s)for(var o of s(e))p.call(e,o)&&a(t,o,e[o]);return t},d=(t,e)=>T(t,m(e));var z=(t,e)=>{for(var o in e)r(t,o,{get:e[o],enumerable:!0})},g=(t,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of S(e))!u.call(t,l)&&l!==o&&r(t,l,{get:()=>e[l],enumerable:!(c=b(e,l))||c.enumerable});return t};var P=(t,e,o)=>(o=t!=null?f($(t)):{},g(e||!t||!t.__esModule?r(o,"default",{value:t,enumerable:!0}):o,t)),B=t=>g(r({},"__esModule",{value:!0}),t);var D={};z(D,{default:()=>y});module.exports=B(D);var h=require("react-native"),n=P(require("styled-components/native"));var i=require("react/jsx-runtime");function y(t){let e=(0,n.useTheme)();return(0,i.jsx)(H,d(x({testID:"button"},t),{children:t.isLoading?(0,i.jsx)(h.ActivityIndicator,{testID:"loading-indicator",color:e.colors.container.default,size:25}):(0,i.jsx)(i.Fragment,{children:t.children?t.children:(0,i.jsx)(I,{style:t.textStyle,children:t.text})})}))}var H=n.default.TouchableHighlight`
|
|
2
|
+
background-color: ${({theme:t})=>t.colors.button.default};
|
|
3
|
+
min-height: ${({theme:t})=>t.layout.height(2)}px;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
align-items: center;
|
|
6
|
+
border-radius: ${({theme:t})=>t.layout.size(2)}px;
|
|
7
|
+
margin: ${({theme:t})=>t.layout.size(1)}px;
|
|
8
|
+
padding: ${({theme:t})=>t.layout.size(2)}px;
|
|
9
|
+
|
|
10
|
+
${({disabled:t})=>t&&n.css`
|
|
11
|
+
opacity: 0.5;
|
|
12
|
+
`}
|
|
13
|
+
`,I=n.default.Text`
|
|
14
|
+
color: ${({theme:t})=>t.colors.text.contrast};
|
|
15
|
+
font-size: ${({theme:t})=>t.fonts.size(16)}px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
`;
|
package/package.json
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilestock-native/button",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"main": "
|
|
5
|
-
"files": [
|
|
6
|
-
"*"
|
|
7
|
-
],
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"default": "./src/index.tsx"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"main": "index.js",
|
|
13
5
|
"peerDependencies": {
|
|
14
|
-
"react": "
|
|
15
|
-
"react-dom": "
|
|
16
|
-
"
|
|
6
|
+
"react": "18.2.0",
|
|
7
|
+
"react-dom": "18.2.0",
|
|
8
|
+
"react-native": "0.74.5",
|
|
9
|
+
"styled-components": "^6.1.8"
|
|
17
10
|
}
|
|
18
11
|
}
|
package/src/index.tsx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from 'react'
|
|
2
|
-
import { ActivityIndicator, StyleProp, TextStyle, TouchableHighlightProps } from 'react-native'
|
|
3
|
-
import styled, { css, useTheme } from 'styled-components/native'
|
|
4
|
-
|
|
5
|
-
export interface PropsButton extends TouchableHighlightProps {
|
|
6
|
-
text?: string
|
|
7
|
-
isLoading?: boolean
|
|
8
|
-
textStyle?: StyleProp<TextStyle>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const Button: React.FC<PropsWithChildren<PropsButton>> = (props) => {
|
|
12
|
-
const theme = useTheme()
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<ButtonStyle testID="button" {...props}>
|
|
16
|
-
{props.isLoading ? (
|
|
17
|
-
<ActivityIndicator testID="loading-indicator" color={theme.colors.container.default} size={25} />
|
|
18
|
-
) : (
|
|
19
|
-
<>{props.children ? props.children : <Text style={props.textStyle}>{props.text}</Text>}</>
|
|
20
|
-
)}
|
|
21
|
-
</ButtonStyle>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const ButtonStyle = styled.TouchableHighlight`
|
|
26
|
-
background-color: ${({ theme }) => theme.colors.button.default};
|
|
27
|
-
min-height: ${({ theme }) => theme.layout.height(2)}px;
|
|
28
|
-
justify-content: center;
|
|
29
|
-
align-items: center;
|
|
30
|
-
border-radius: ${({ theme }) => theme.layout.size(2)}px;
|
|
31
|
-
margin: ${({ theme }) => theme.layout.size(1)}px;
|
|
32
|
-
padding: ${({ theme }) => theme.layout.size(2)}px;
|
|
33
|
-
|
|
34
|
-
${({ disabled }) =>
|
|
35
|
-
disabled &&
|
|
36
|
-
css`
|
|
37
|
-
opacity: 0.5;
|
|
38
|
-
`}
|
|
39
|
-
`
|
|
40
|
-
|
|
41
|
-
const Text = styled.Text`
|
|
42
|
-
color: ${({ theme }) => theme.colors.text.contrast};
|
|
43
|
-
font-size: ${({ theme }) => theme.fonts.size(16)}px;
|
|
44
|
-
text-align: center;
|
|
45
|
-
`
|
|
46
|
-
|
|
47
|
-
export default Button
|