@startupjs-ui/card 0.1.3
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/CHANGELOG.md +20 -0
- package/README.mdx +143 -0
- package/index.cssx.styl +10 -0
- package/index.d.ts +19 -0
- package/index.tsx +40 -0
- package/package.json +20 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.1.3](https://github.com/startupjs/startupjs-ui/compare/v0.1.2...v0.1.3) (2025-12-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @startupjs-ui/card
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.1.2](https://github.com/startupjs/startupjs-ui/compare/v0.1.1...v0.1.2) (2025-12-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add mdx and docs packages. Refactor docs to get rid of any @startupjs/ui usage and use startupjs-ui instead ([703c926](https://github.com/startupjs/startupjs-ui/commit/703c92636efb0421ffd11783f692fc892b74018f))
|
|
20
|
+
* **card:** refactor Card component ([91b6de8](https://github.com/startupjs/startupjs-ui/commit/91b6de8d04ea072a306d3d4ef482aad0a3969a14))
|
package/README.mdx
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Image } from 'react-native'
|
|
3
|
+
import { u } from 'startupjs'
|
|
4
|
+
import { Sandbox } from '@startupjs-ui/docs'
|
|
5
|
+
import Span from '@startupjs-ui/span'
|
|
6
|
+
import Collapse from '@startupjs-ui/collapse'
|
|
7
|
+
import Button from '@startupjs-ui/button'
|
|
8
|
+
import Card, { _PropsJsonSchema as CardPropsJsonSchema } from './index'
|
|
9
|
+
import Br from '@startupjs-ui/br'
|
|
10
|
+
import Div from '@startupjs-ui/div'
|
|
11
|
+
import { faShareAlt } from '@fortawesome/free-solid-svg-icons'
|
|
12
|
+
|
|
13
|
+
# Card
|
|
14
|
+
Inherits [Div props](/docs/components/Div).
|
|
15
|
+
|
|
16
|
+
Cards contain content and actions about a single subject.
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
import { Card } from 'startupjs-ui'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Simple example
|
|
23
|
+
|
|
24
|
+
Although cards can support multiple actions, UI controls, and an overflow menu, use restraint and remember that cards are entry points to more complex and detailed information.
|
|
25
|
+
|
|
26
|
+
```jsx example
|
|
27
|
+
return (
|
|
28
|
+
<Card>
|
|
29
|
+
<Span h4>Card header</Span>
|
|
30
|
+
<Br />
|
|
31
|
+
<Span>Card body</Span>
|
|
32
|
+
</Card>
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Outlined cards
|
|
37
|
+
|
|
38
|
+
Outlined cards offer an alternative style by passing `outlined` string on `variant` property to component.
|
|
39
|
+
|
|
40
|
+
```jsx example
|
|
41
|
+
return (
|
|
42
|
+
<Card variant='outlined'>
|
|
43
|
+
<Span h4>Card header</Span>
|
|
44
|
+
<Br />
|
|
45
|
+
<Span>Card body</Span>
|
|
46
|
+
</Card>
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Levels of emphasis
|
|
51
|
+
|
|
52
|
+
Card `level` prop determines different levels of emphasis, depending on its level of hierarchy. It only make sense when the `variant` is `elevated` (default).
|
|
53
|
+
|
|
54
|
+
```jsx example
|
|
55
|
+
return (
|
|
56
|
+
<Div>
|
|
57
|
+
<Card>
|
|
58
|
+
<Span h4>Card Level - 1</Span>
|
|
59
|
+
<Br />
|
|
60
|
+
<Span>Card body</Span>
|
|
61
|
+
</Card>
|
|
62
|
+
<Br />
|
|
63
|
+
<Card level={2}>
|
|
64
|
+
<Span h4>Card Level - 2</Span>
|
|
65
|
+
<Br />
|
|
66
|
+
<Span>Card body</Span>
|
|
67
|
+
</Card>
|
|
68
|
+
<Br />
|
|
69
|
+
<Card level={3}>
|
|
70
|
+
<Span h4>Card Level - 3</Span>
|
|
71
|
+
<Br />
|
|
72
|
+
<Span>Card body</Span>
|
|
73
|
+
</Card>
|
|
74
|
+
<Br />
|
|
75
|
+
<Card level={4}>
|
|
76
|
+
<Span h4>Card Level - 4</Span>
|
|
77
|
+
<Br />
|
|
78
|
+
<Span>Card body</Span>
|
|
79
|
+
</Card>
|
|
80
|
+
</Div>
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Complex interaction (intergration with other components)
|
|
85
|
+
|
|
86
|
+
```jsx example
|
|
87
|
+
const style = { maxWidth: u(50) }
|
|
88
|
+
const imageStyle = { height: u(40), resizeMode: 'cover' }
|
|
89
|
+
const [collapsed, setCollapsed] = useState(false)
|
|
90
|
+
return (
|
|
91
|
+
<Card
|
|
92
|
+
style={style}
|
|
93
|
+
>
|
|
94
|
+
<Image
|
|
95
|
+
source={{ uri: '/img/cat.webp' }}
|
|
96
|
+
style={imageStyle}
|
|
97
|
+
/>
|
|
98
|
+
<Br />
|
|
99
|
+
<Span h4>Cat</Span>
|
|
100
|
+
<Br />
|
|
101
|
+
<Span>
|
|
102
|
+
The cat (Felis catus) is a domestic species of small carnivorous mammal.
|
|
103
|
+
</Span>
|
|
104
|
+
<Br />
|
|
105
|
+
<Div row align='between'>
|
|
106
|
+
<Button
|
|
107
|
+
onPress={() => setCollapsed(!collapsed)}
|
|
108
|
+
variant='flat'
|
|
109
|
+
>
|
|
110
|
+
Learn more
|
|
111
|
+
</Button>
|
|
112
|
+
<Button
|
|
113
|
+
pushed
|
|
114
|
+
icon={faShareAlt}
|
|
115
|
+
onPress={() => null}
|
|
116
|
+
>
|
|
117
|
+
Share
|
|
118
|
+
</Button>
|
|
119
|
+
</Div>
|
|
120
|
+
<Br />
|
|
121
|
+
<Collapse open={collapsed} variant='pure' icon={false}>
|
|
122
|
+
<Collapse.Content>
|
|
123
|
+
It is the only domesticated species in the family Felidae and is often referred to as the domestic cat to distinguish it from the wild members of the family. A cat can either be a house cat, a farm cat or a feral cat; the latter ranges freely and avoids human contact. Domestic cats are valued by humans for companionship and their ability to hunt pests such as rodents. About 60 cat breeds are recognized by various cat registries. (source: wiki)
|
|
124
|
+
</Collapse.Content>
|
|
125
|
+
</Collapse>
|
|
126
|
+
</Card>
|
|
127
|
+
)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Sandbox
|
|
131
|
+
|
|
132
|
+
<Sandbox
|
|
133
|
+
Component={Card}
|
|
134
|
+
propsJsonSchema={CardPropsJsonSchema}
|
|
135
|
+
props={{
|
|
136
|
+
children: [
|
|
137
|
+
<Span h4 key='header'>Card header</Span>,
|
|
138
|
+
<Br key='br'/>,
|
|
139
|
+
<Span key='body'>Card body</Span>
|
|
140
|
+
],
|
|
141
|
+
onPress: () => alert('"onPress" event on "Card" component'),
|
|
142
|
+
}}
|
|
143
|
+
/>
|
package/index.cssx.styl
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// DO NOT MODIFY THIS FILE - IT IS AUTOMATICALLY GENERATED ON COMMITS.
|
|
3
|
+
|
|
4
|
+
import { type ReactNode } from 'react';
|
|
5
|
+
import { type DivProps } from '@startupjs-ui/div';
|
|
6
|
+
import './index.cssx.styl';
|
|
7
|
+
declare const _default: import("react").ComponentType<CardProps>;
|
|
8
|
+
export default _default;
|
|
9
|
+
export declare const _PropsJsonSchema: {};
|
|
10
|
+
export interface CardProps extends Omit<DivProps, 'variant' | 'level' | 'children' | 'style'> {
|
|
11
|
+
/** Custom styles applied to the root view */
|
|
12
|
+
style?: DivProps['style'];
|
|
13
|
+
/** Content rendered inside Card */
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
/** Shadow intensity level @default 1 */
|
|
16
|
+
level?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
17
|
+
/** Visual appearance variant @default 'elevated' */
|
|
18
|
+
variant?: 'elevated' | 'outlined';
|
|
19
|
+
}
|
package/index.tsx
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ReactNode } from 'react'
|
|
2
|
+
import { pug, observer } from 'startupjs'
|
|
3
|
+
import { themed } from '@startupjs-ui/core'
|
|
4
|
+
import Div, { type DivProps } from '@startupjs-ui/div'
|
|
5
|
+
import './index.cssx.styl'
|
|
6
|
+
|
|
7
|
+
export default observer(themed('Card', Card))
|
|
8
|
+
|
|
9
|
+
export const _PropsJsonSchema = {/* CardProps */}
|
|
10
|
+
|
|
11
|
+
export interface CardProps extends Omit<DivProps, 'variant' | 'level' | 'children' | 'style'> {
|
|
12
|
+
/** Custom styles applied to the root view */
|
|
13
|
+
style?: DivProps['style']
|
|
14
|
+
/** Content rendered inside Card */
|
|
15
|
+
children?: ReactNode
|
|
16
|
+
/** Shadow intensity level @default 1 */
|
|
17
|
+
level?: 0 | 1 | 2 | 3 | 4 | 5
|
|
18
|
+
/** Visual appearance variant @default 'elevated' */
|
|
19
|
+
variant?: 'elevated' | 'outlined'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function Card ({
|
|
23
|
+
style,
|
|
24
|
+
level = 1,
|
|
25
|
+
children,
|
|
26
|
+
variant = 'elevated',
|
|
27
|
+
onPress,
|
|
28
|
+
...props
|
|
29
|
+
}: CardProps): ReactNode {
|
|
30
|
+
return pug`
|
|
31
|
+
Div.root(
|
|
32
|
+
style=style
|
|
33
|
+
styleName=[variant]
|
|
34
|
+
onPress=onPress
|
|
35
|
+
level=variant === 'elevated' ? level : undefined
|
|
36
|
+
...props
|
|
37
|
+
)
|
|
38
|
+
= children
|
|
39
|
+
`
|
|
40
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@startupjs-ui/card",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"main": "index.tsx",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@startupjs-ui/core": "^0.1.3",
|
|
12
|
+
"@startupjs-ui/div": "^0.1.3"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"react": "*",
|
|
16
|
+
"react-native": "*",
|
|
17
|
+
"startupjs": "*"
|
|
18
|
+
},
|
|
19
|
+
"gitHead": "fd964ebc3892d3dd0a6c85438c0af619cc50c3f0"
|
|
20
|
+
}
|