@startupjs-ui/content 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 +193 -0
- package/index.cssx.styl +35 -0
- package/index.d.ts +22 -0
- package/index.mdx.cssx.styl +6 -0
- package/index.tsx +54 -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/content
|
|
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
|
+
* **content:** refactor Content component ([ad8cafd](https://github.com/startupjs/startupjs-ui/commit/ad8cafddbe01d30744efdf5eecfe3970247aa91a))
|
package/README.mdx
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { u } from 'startupjs'
|
|
2
|
+
import { Sandbox } from '@startupjs-ui/docs'
|
|
3
|
+
import Content, { _PropsJsonSchema as ContentPropsJsonSchema } from './index'
|
|
4
|
+
import Br from '@startupjs-ui/br'
|
|
5
|
+
import Div from '@startupjs-ui/div'
|
|
6
|
+
import Span from '@startupjs-ui/span'
|
|
7
|
+
import './index.mdx.cssx.styl'
|
|
8
|
+
|
|
9
|
+
# Content
|
|
10
|
+
|
|
11
|
+
Content used as a parent container for the main content area of your app/website.
|
|
12
|
+
|
|
13
|
+
It has good defaults for paddings from sides of the screen and by default limits the maximum width of the content
|
|
14
|
+
to what is usually considered a comfortable reading width - `768px`, which is roughly the width of a tablet in portrait mode.
|
|
15
|
+
|
|
16
|
+
```jsx
|
|
17
|
+
import { Content } from 'startupjs-ui'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Simple Example
|
|
21
|
+
|
|
22
|
+
By default content has left and right paddings of `16px`.
|
|
23
|
+
|
|
24
|
+
```jsx example
|
|
25
|
+
const contentStyle = {
|
|
26
|
+
backgroundColor: '#2962FF'
|
|
27
|
+
}
|
|
28
|
+
const divStyle = {
|
|
29
|
+
height: u(25),
|
|
30
|
+
backgroundColor: '#00AED6',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
justifyContent: 'center'
|
|
33
|
+
}
|
|
34
|
+
return (
|
|
35
|
+
<Content style={contentStyle}>
|
|
36
|
+
<Div style={divStyle}>
|
|
37
|
+
<Span>content</Span>
|
|
38
|
+
</Div>
|
|
39
|
+
</Content>
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## No horizontal paddings
|
|
44
|
+
|
|
45
|
+
Pass `pure` property to remove left and right paddings. You would want to do this to keep the behaviour of
|
|
46
|
+
limiting the maximum width of the Content (`768px` by default) while handling the internal paddings yourself.
|
|
47
|
+
|
|
48
|
+
This is useful when creating lists, tables, or other components that on small screens need to look like they go
|
|
49
|
+
all the way from left to right. While on the bigger screens you would still want to limit the maximum width of the content.
|
|
50
|
+
|
|
51
|
+
```jsx example
|
|
52
|
+
const contentStyle = {
|
|
53
|
+
backgroundColor: '#2962FF'
|
|
54
|
+
}
|
|
55
|
+
const divStyle = {
|
|
56
|
+
height: u(25),
|
|
57
|
+
backgroundColor: '#00AED6',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
justifyContent: 'center'
|
|
60
|
+
}
|
|
61
|
+
return (
|
|
62
|
+
<Content style={contentStyle} pure>
|
|
63
|
+
<Div style={divStyle}>
|
|
64
|
+
<Span>content</Span>
|
|
65
|
+
</Div>
|
|
66
|
+
</Content>
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Vertical paddings
|
|
71
|
+
|
|
72
|
+
Top and bottom paddings can be added by passing the `padding` property to component.
|
|
73
|
+
|
|
74
|
+
```jsx example
|
|
75
|
+
const contentStyle = {
|
|
76
|
+
backgroundColor: '#2962FF'
|
|
77
|
+
}
|
|
78
|
+
const divStyle = {
|
|
79
|
+
height: u(25),
|
|
80
|
+
backgroundColor: '#00AED6',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
justifyContent: 'center'
|
|
83
|
+
}
|
|
84
|
+
return (
|
|
85
|
+
<Content style={contentStyle} padding>
|
|
86
|
+
<Div style={divStyle}>
|
|
87
|
+
<Span>content</Span>
|
|
88
|
+
</Div>
|
|
89
|
+
</Content>
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Full space
|
|
94
|
+
|
|
95
|
+
Content takes the `full` property, which gives it all the empty space on the main `flexbox` axis of the parent.
|
|
96
|
+
|
|
97
|
+
```jsx example
|
|
98
|
+
const divStyle = {
|
|
99
|
+
height: u(25),
|
|
100
|
+
backgroundColor: '#2962FF'
|
|
101
|
+
}
|
|
102
|
+
const contentStyle = {
|
|
103
|
+
backgroundColor: '#00AED6',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
justifyContent: 'center'
|
|
106
|
+
}
|
|
107
|
+
return (
|
|
108
|
+
<Div>
|
|
109
|
+
<Div style={divStyle}>
|
|
110
|
+
<Content style={contentStyle}>
|
|
111
|
+
<Span>Content without full</Span>
|
|
112
|
+
</Content>
|
|
113
|
+
</Div>
|
|
114
|
+
<Br />
|
|
115
|
+
<Div style={divStyle}>
|
|
116
|
+
<Content style={contentStyle} full>
|
|
117
|
+
<Span>Content with full</Span>
|
|
118
|
+
</Content>
|
|
119
|
+
</Div>
|
|
120
|
+
</Div>
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Max width
|
|
125
|
+
|
|
126
|
+
Content has limited max-width by default of `768px`, because we are making mobile first layout and can only go from smaller to larger screens by changing `width` property (possible values of property can be found in the `Sandbox` section at the bottom of the page). Also you can change the default width value for component by overriding `defaultWidth` property in your `$UI.Content.defaultWidth`. **We don't recommend to change the `defaultWidth` unnecessarily, because it is a more advanced setting that will change all your entire app.**
|
|
127
|
+
|
|
128
|
+
```jsx example
|
|
129
|
+
const contentStyle = {
|
|
130
|
+
backgroundColor: '#2962FF'
|
|
131
|
+
}
|
|
132
|
+
const divStyle = {
|
|
133
|
+
height: u(25),
|
|
134
|
+
backgroundColor: '#00AED6',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
justifyContent: 'center'
|
|
137
|
+
}
|
|
138
|
+
return (
|
|
139
|
+
<Div>
|
|
140
|
+
<Content
|
|
141
|
+
style={contentStyle}
|
|
142
|
+
width='mobile'
|
|
143
|
+
padding
|
|
144
|
+
>
|
|
145
|
+
<Div style={divStyle}>
|
|
146
|
+
<Span>Mobile</Span>
|
|
147
|
+
</Div>
|
|
148
|
+
</Content>
|
|
149
|
+
<Br />
|
|
150
|
+
<Content
|
|
151
|
+
style={contentStyle}
|
|
152
|
+
padding
|
|
153
|
+
>
|
|
154
|
+
<Div style={divStyle}>
|
|
155
|
+
<Span>Tablet (default)</Span>
|
|
156
|
+
</Div>
|
|
157
|
+
</Content>
|
|
158
|
+
<Br />
|
|
159
|
+
<Content
|
|
160
|
+
style={contentStyle}
|
|
161
|
+
width='desktop'
|
|
162
|
+
padding
|
|
163
|
+
>
|
|
164
|
+
<Div style={divStyle}>
|
|
165
|
+
<Span>Desktop</Span>
|
|
166
|
+
</Div>
|
|
167
|
+
</Content>
|
|
168
|
+
<Br />
|
|
169
|
+
<Content
|
|
170
|
+
style={contentStyle}
|
|
171
|
+
width='wide'
|
|
172
|
+
padding
|
|
173
|
+
>
|
|
174
|
+
<Div style={divStyle}>
|
|
175
|
+
<Span>Full Width</Span>
|
|
176
|
+
</Div>
|
|
177
|
+
</Content>
|
|
178
|
+
</Div>
|
|
179
|
+
)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Sandbox
|
|
183
|
+
|
|
184
|
+
<Sandbox
|
|
185
|
+
Component={Content}
|
|
186
|
+
props={{
|
|
187
|
+
style: { backgroundColor: '#2962FF' },
|
|
188
|
+
children: <Div styleName='child' />,
|
|
189
|
+
}}
|
|
190
|
+
propsJsonSchema={ContentPropsJsonSchema}
|
|
191
|
+
rendererStyleName='renderer'
|
|
192
|
+
block
|
|
193
|
+
/>
|
package/index.cssx.styl
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// ----- CONFIG: $UI.Content
|
|
2
|
+
|
|
3
|
+
$this = merge({
|
|
4
|
+
defaultWidth: 'tablet'
|
|
5
|
+
}, $UI.Content, true)
|
|
6
|
+
|
|
7
|
+
// ----- COMPONENT
|
|
8
|
+
|
|
9
|
+
_gutter = 2u
|
|
10
|
+
|
|
11
|
+
.root
|
|
12
|
+
padding-left _gutter
|
|
13
|
+
padding-right @padding-left
|
|
14
|
+
align-self center
|
|
15
|
+
width 100%
|
|
16
|
+
|
|
17
|
+
&.pure
|
|
18
|
+
padding-left 0
|
|
19
|
+
padding-right 0
|
|
20
|
+
|
|
21
|
+
&.width
|
|
22
|
+
&-mobile
|
|
23
|
+
max-width: $UI.media.mobile
|
|
24
|
+
&-tablet
|
|
25
|
+
max-width: $UI.media.tablet
|
|
26
|
+
&-desktop
|
|
27
|
+
max-width: $UI.media.desktop
|
|
28
|
+
&-wide
|
|
29
|
+
max-width: $UI.media.wide
|
|
30
|
+
// &-full is without max-width
|
|
31
|
+
|
|
32
|
+
// ----- JS EXPORTS
|
|
33
|
+
|
|
34
|
+
:export
|
|
35
|
+
config: $this
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
declare const _default: import("react").ComponentType<ContentProps>;
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare const _PropsJsonSchema: {};
|
|
9
|
+
export interface ContentProps extends Omit<DivProps, 'style' | 'padding' | 'full'> {
|
|
10
|
+
/** Custom styles applied to the root view */
|
|
11
|
+
style?: DivProps['style'];
|
|
12
|
+
/** Content rendered inside wrapper */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** Add equal top and bottom padding. true maps to default spacing @default false */
|
|
15
|
+
padding?: boolean | number;
|
|
16
|
+
/** Expand to take full available space in parent flex layout @default false */
|
|
17
|
+
full?: boolean;
|
|
18
|
+
/** Content width preset @default 'tablet' */
|
|
19
|
+
width?: 'mobile' | 'tablet' | 'desktop' | 'wide' | 'full';
|
|
20
|
+
/** Remove horizontal paddings */
|
|
21
|
+
pure?: boolean;
|
|
22
|
+
}
|
package/index.tsx
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ReactNode } from 'react'
|
|
2
|
+
import { pug, observer, u } from 'startupjs'
|
|
3
|
+
import { themed } from '@startupjs-ui/core'
|
|
4
|
+
import Div, { type DivProps } from '@startupjs-ui/div'
|
|
5
|
+
import STYLES from './index.cssx.styl'
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
config: { defaultWidth }
|
|
9
|
+
} = STYLES
|
|
10
|
+
|
|
11
|
+
export default observer(themed('Content', Content))
|
|
12
|
+
|
|
13
|
+
export const _PropsJsonSchema = {/* ContentProps */}
|
|
14
|
+
|
|
15
|
+
export interface ContentProps extends Omit<DivProps, 'style' | 'padding' | 'full'> {
|
|
16
|
+
/** Custom styles applied to the root view */
|
|
17
|
+
style?: DivProps['style']
|
|
18
|
+
/** Content rendered inside wrapper */
|
|
19
|
+
children?: ReactNode
|
|
20
|
+
/** Add equal top and bottom padding. true maps to default spacing @default false */
|
|
21
|
+
padding?: boolean | number
|
|
22
|
+
/** Expand to take full available space in parent flex layout @default false */
|
|
23
|
+
full?: boolean
|
|
24
|
+
/** Content width preset @default 'tablet' */
|
|
25
|
+
width?: 'mobile' | 'tablet' | 'desktop' | 'wide' | 'full'
|
|
26
|
+
/** Remove horizontal paddings */
|
|
27
|
+
pure?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function Content ({
|
|
31
|
+
children,
|
|
32
|
+
padding = false,
|
|
33
|
+
pure,
|
|
34
|
+
width = defaultWidth,
|
|
35
|
+
full = false,
|
|
36
|
+
...props
|
|
37
|
+
}: ContentProps): ReactNode {
|
|
38
|
+
const _rootStyle: Record<string, any> = {}
|
|
39
|
+
if (padding === true) padding = 2
|
|
40
|
+
if (typeof padding === 'number') {
|
|
41
|
+
_rootStyle.paddingTop = u(padding)
|
|
42
|
+
_rootStyle.paddingBottom = u(padding)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return pug`
|
|
46
|
+
Div.root(
|
|
47
|
+
part='root'
|
|
48
|
+
style=_rootStyle
|
|
49
|
+
styleName=['width-' + width, { pure }]
|
|
50
|
+
full=full
|
|
51
|
+
...props
|
|
52
|
+
)= children
|
|
53
|
+
`
|
|
54
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@startupjs-ui/content",
|
|
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
|
+
}
|