@startupjs-ui/progress 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 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/progress
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
+ * **progress:** refactor Progress component ([d32d2b6](https://github.com/startupjs/startupjs-ui/commit/d32d2b626f71281aeced05ec89f11d1b0b79a0db))
package/README.mdx ADDED
@@ -0,0 +1,67 @@
1
+ import { useState, useEffect } from 'react'
2
+ import Progress, { _PropsJsonSchema as ProgressPropsJsonSchema } from './index'
3
+ import { Sandbox } from '@startupjs-ui/docs'
4
+ import Button from '@startupjs-ui/button'
5
+ import Br from '@startupjs-ui/br'
6
+
7
+ # Progress
8
+
9
+ Progress is used to display the length of process, for example upload or download files.
10
+
11
+ ```jsx
12
+ import { Progress } from 'startupjs-ui'
13
+ ```
14
+
15
+ ## Simple example
16
+
17
+ ```jsx example
18
+ return (
19
+ <Progress value={10} />
20
+ )
21
+ ```
22
+
23
+ ## Interactive
24
+
25
+ ```jsx example
26
+ const [value, setValue] = useState(0)
27
+ const [startProgress, setStartProgress] = useState(false)
28
+ const [countdown, setCountdown] = useState(false)
29
+
30
+ useEffect(() => {
31
+ let interval
32
+ if (startProgress) {
33
+ interval = setInterval(() => {
34
+ setValue(v => {
35
+ const nextValue = countdown ? v - 1 : v + 1
36
+ if (nextValue === 100 || nextValue === 0) {
37
+ setCountdown(!countdown)
38
+ }
39
+ return nextValue
40
+ })
41
+ }, 100)
42
+ }
43
+ return () => clearInterval(interval)
44
+ }, [startProgress, countdown])
45
+
46
+ return (
47
+ <>
48
+ <Progress value={value} />
49
+ <Br />
50
+ <Button onPress={() => setStartProgress(!startProgress)}>
51
+ {startProgress ? 'Stop' : 'Start'}
52
+ </Button>
53
+ </>
54
+ )
55
+ ```
56
+
57
+ ## Caption
58
+
59
+ ```jsx example
60
+ return (
61
+ <Progress value={50}>50 of 100</Progress>
62
+ )
63
+ ```
64
+
65
+ ## Sandbox
66
+
67
+ <Sandbox Component={Progress} propsJsonSchema={ProgressPropsJsonSchema} block />
package/filler.tsx ADDED
@@ -0,0 +1,59 @@
1
+ import { useState, type ReactNode } from 'react'
2
+ import {
3
+ Animated,
4
+ Easing,
5
+ type StyleProp,
6
+ type ViewStyle
7
+ } from 'react-native'
8
+ import { pug, observer, useDidUpdate } from 'startupjs'
9
+ import { themed } from '@startupjs-ui/core'
10
+ import STYLES from './index.cssx.styl'
11
+
12
+ const {
13
+ config: {
14
+ duration
15
+ }
16
+ } = STYLES
17
+
18
+ const AnimatedView = Animated.View
19
+
20
+ interface ProgressFillerProps {
21
+ style?: StyleProp<ViewStyle>
22
+ value: number
23
+ }
24
+
25
+ function ProgressFiller ({ style, value }: ProgressFillerProps): ReactNode {
26
+ const [progress] = useState(() => new Animated.Value(value))
27
+ const [width, setWidth] = useState(0)
28
+
29
+ useDidUpdate(() => {
30
+ Animated.timing(
31
+ progress,
32
+ {
33
+ toValue: value,
34
+ duration,
35
+ easing: Easing.linear,
36
+ useNativeDriver: true
37
+ }
38
+ ).start()
39
+ }, [value])
40
+
41
+ return pug`
42
+ AnimatedView.filler(
43
+ style=[
44
+ style,
45
+ {
46
+ transform: [{
47
+ translateX: progress.interpolate({
48
+ inputRange: [0, 100],
49
+ outputRange: [-width, 0]
50
+ })
51
+ }]
52
+ }
53
+ ]
54
+ onLayout=(event) => setWidth(event.nativeEvent.layout.width)
55
+ )
56
+ `
57
+ }
58
+
59
+ export default observer(themed('Progress', ProgressFiller))
package/filler.web.tsx ADDED
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from 'react'
2
+ import { View, type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import './index.cssx.styl'
6
+
7
+ interface ProgressFillerProps {
8
+ style?: StyleProp<ViewStyle>
9
+ value: number
10
+ }
11
+
12
+ function ProgressFiller ({ style, value }: ProgressFillerProps): ReactNode {
13
+ return pug`
14
+ View.filler(style=[{ width: value + '%' }, style])
15
+ `
16
+ }
17
+
18
+ export default observer(themed('Progress', ProgressFiller))
@@ -0,0 +1,31 @@
1
+ // ----- CONFIG: $UI.Progress
2
+
3
+ $this = merge({
4
+ duration: 300
5
+ }, $UI.Progress, true)
6
+
7
+ // ----- COMPONENT
8
+
9
+ _backgroundColor = var(--color-bg-main-subtle-alt)
10
+ _fillerColor = var(--color-bg-success)
11
+ _duration = $this.duration
12
+
13
+ .progress
14
+ background-color _backgroundColor
15
+ overflow hidden
16
+
17
+ .filler
18
+ height _size
19
+ background-color _fillerColor
20
+
21
+ +web()
22
+ transition width (_duration/1000)s
23
+
24
+ .label
25
+ margin-top 2px
26
+ font(caption)
27
+
28
+ // ----- JS EXPORTS
29
+
30
+ :export
31
+ config: $this
package/index.d.ts ADDED
@@ -0,0 +1,28 @@
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 StyleProp, type ViewStyle } from 'react-native';
6
+ import { type DivProps } from '@startupjs-ui/div';
7
+ import './index.cssx.styl';
8
+ declare const _default: import("react").ComponentType<ProgressProps>;
9
+ export default _default;
10
+ export declare const _PropsJsonSchema: {};
11
+ export interface ProgressProps {
12
+ /** Custom styles applied to the wrapper */
13
+ style?: StyleProp<ViewStyle>;
14
+ /** Percent value between 0 and 100 @default 0 */
15
+ value?: number;
16
+ /** Label content rendered under the progress bar */
17
+ children?: ReactNode;
18
+ /** Progress visual variant @default 'linear' */
19
+ variant?: 'linear' | 'circular';
20
+ /** Shape of the progress track @default 'rounded' */
21
+ shape?: DivProps['shape'];
22
+ /** Height of the progress bar @default u(0.5) */
23
+ width?: number;
24
+ /** Style overrides for the progress track part */
25
+ progressStyle?: DivProps['style'];
26
+ /** Style overrides for the filler part */
27
+ fillerStyle?: StyleProp<ViewStyle>;
28
+ }
package/index.tsx ADDED
@@ -0,0 +1,53 @@
1
+ import { type ReactNode } from 'react'
2
+ import { View, type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer, u } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import Div, { type DivProps } from '@startupjs-ui/div'
6
+ import Span from '@startupjs-ui/span'
7
+ import Filler from './filler'
8
+ import './index.cssx.styl'
9
+
10
+ export default observer(themed('Progress', Progress))
11
+
12
+ export const _PropsJsonSchema = {/* ProgressProps */}
13
+
14
+ export interface ProgressProps {
15
+ /** Custom styles applied to the wrapper */
16
+ style?: StyleProp<ViewStyle>
17
+ /** Percent value between 0 and 100 @default 0 */
18
+ value?: number
19
+ /** Label content rendered under the progress bar */
20
+ children?: ReactNode
21
+ /** Progress visual variant @default 'linear' */
22
+ variant?: 'linear' | 'circular'
23
+ /** Shape of the progress track @default 'rounded' */
24
+ shape?: DivProps['shape']
25
+ /** Height of the progress bar @default u(0.5) */
26
+ width?: number
27
+ /** Style overrides for the progress track part */
28
+ progressStyle?: DivProps['style']
29
+ /** Style overrides for the filler part */
30
+ fillerStyle?: StyleProp<ViewStyle>
31
+ }
32
+
33
+ function Progress ({
34
+ style,
35
+ value = 0,
36
+ children,
37
+ variant = 'linear',
38
+ shape = 'rounded',
39
+ width = u(0.5)
40
+ }: ProgressProps): ReactNode {
41
+ const extraStyle = { height: width }
42
+
43
+ return pug`
44
+ View(style=style)
45
+ Div.progress(part='progress' style=extraStyle shape=shape)
46
+ //- To normalize value pass value=Math.min(value, 100)
47
+ Filler(part='filler' style=extraStyle value=value)
48
+ if typeof children === 'string'
49
+ Span.label= children
50
+ else
51
+ = children
52
+ `
53
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@startupjs-ui/progress",
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
+ "@startupjs-ui/span": "^0.1.3"
14
+ },
15
+ "peerDependencies": {
16
+ "react": "*",
17
+ "react-native": "*",
18
+ "startupjs": "*"
19
+ },
20
+ "gitHead": "fd964ebc3892d3dd0a6c85438c0af619cc50c3f0"
21
+ }