@startupjs-ui/progress 0.1.13 → 0.1.18

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 CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.1.18](https://github.com/startupjs/startupjs-ui/compare/v0.1.17...v0.1.18) (2026-02-23)
7
+
8
+
9
+ ### Features
10
+
11
+ * add rounded progress ([#16](https://github.com/startupjs/startupjs-ui/issues/16)) ([d219deb](https://github.com/startupjs/startupjs-ui/commit/d219deb050cd352852d8fad2c09044ead1106bb7))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.1.16](https://github.com/startupjs/startupjs-ui/compare/v0.1.15...v0.1.16) (2026-02-10)
18
+
19
+ **Note:** Version bump only for package @startupjs-ui/progress
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.1.13](https://github.com/startupjs/startupjs-ui/compare/v0.1.12...v0.1.13) (2026-02-03)
7
26
 
8
27
  **Note:** Version bump only for package @startupjs-ui/progress
package/README.mdx CHANGED
@@ -6,7 +6,9 @@ import Br from '@startupjs-ui/br'
6
6
 
7
7
  # Progress
8
8
 
9
- Progress is used to display the length of process, for example upload or download files.
9
+ Progress displays the completion status of a process, such as a file upload or download. The `value` prop sets the progress percentage (0 to 100, defaults to `0`).
10
+
11
+ The component supports two visual variants via the `variant` prop: `'linear'` (default) and `'circular'`. You can customize the bar height with the `width` prop, the track shape with the `shape` prop (defaults to `'rounded'`), and apply custom styles using `style` for the wrapper, `progressStyle` for the progress track, and `fillerStyle` for the filled portion.
10
12
 
11
13
  ```jsx
12
14
  import { Progress } from 'startupjs-ui'
@@ -22,6 +24,8 @@ return (
22
24
 
23
25
  ## Interactive
24
26
 
27
+ The progress bar animates smoothly as the `value` changes.
28
+
25
29
  ```jsx example
26
30
  const [value, setValue] = useState(0)
27
31
  const [startProgress, setStartProgress] = useState(false)
@@ -56,6 +60,8 @@ return (
56
60
 
57
61
  ## Caption
58
62
 
63
+ Pass `children` to display a label below the progress bar.
64
+
59
65
  ```jsx example
60
66
  return (
61
67
  <Progress value={50}>50 of 100</Progress>
@@ -0,0 +1,73 @@
1
+ import { useState, type ReactNode } from 'react'
2
+ import { View, type StyleProp, type ViewStyle } from 'react-native'
3
+ import Svg, { Circle } from 'react-native-svg'
4
+ import { pug, observer, u } from 'startupjs'
5
+ import { themed, getCssVariable } from '@startupjs-ui/core'
6
+ import STYLE from './index.cssx.styl'
7
+
8
+ const { config: { filler: { backgroundColor, color } } } = STYLE
9
+
10
+ interface CircleFillerProps {
11
+ style?: StyleProp<ViewStyle>
12
+ value?: number
13
+ width?: number
14
+ }
15
+
16
+ function resolveCssVarString (value: string) {
17
+ const match = String(value || '').match(/^var\((--[^)]+)\)$/)
18
+ if (!match) return value
19
+ return getCssVariable(match[1], { convertToString: true }) ?? value
20
+ }
21
+
22
+ function CircleFiller ({
23
+ style,
24
+ value = 0,
25
+ width = u(0.5)
26
+ }: CircleFillerProps): ReactNode {
27
+ const [layoutSize, setLayoutSize] = useState(0)
28
+
29
+ const normalizedValue = Math.max(0, Math.min(100, value))
30
+ const diameter = layoutSize > 0 ? layoutSize : u(5)
31
+ const strokeWidth = Math.max(2, Number(width) || 2)
32
+ const radius = (diameter - strokeWidth) / 2
33
+ const circumference = 2 * Math.PI * radius
34
+ const strokeDashoffset = circumference * (1 - normalizedValue / 100)
35
+
36
+ const trackColor = resolveCssVarString(backgroundColor)
37
+ const valueColor = resolveCssVarString(color)
38
+
39
+ return pug`
40
+ View(
41
+ style=[style]
42
+ onLayout=(event) => {
43
+ const { width, height } = event.nativeEvent.layout || {}
44
+ const nextSize = Math.min(width || 0, height || 0)
45
+ if (nextSize > 0 && nextSize !== layoutSize) setLayoutSize(nextSize)
46
+ }
47
+ )
48
+ Svg(width=diameter height=diameter)
49
+ Circle(
50
+ cx=diameter / 2
51
+ cy=diameter / 2
52
+ r=radius
53
+ stroke=trackColor
54
+ strokeWidth=strokeWidth
55
+ fill='none'
56
+ )
57
+ Circle(
58
+ cx=diameter / 2
59
+ cy=diameter / 2
60
+ r=radius
61
+ stroke=valueColor
62
+ strokeWidth=strokeWidth
63
+ fill='none'
64
+ strokeLinecap='round'
65
+ strokeDasharray=[circumference, circumference]
66
+ strokeDashoffset=strokeDashoffset
67
+ rotation='-90'
68
+ origin=(diameter / 2) + ', ' + (diameter / 2)
69
+ )
70
+ `
71
+ }
72
+
73
+ export default observer(themed('Progress', CircleFiller))
package/index.cssx.styl CHANGED
@@ -1,22 +1,26 @@
1
1
  // ----- CONFIG: $UI.Progress
2
2
 
3
3
  $this = merge({
4
- duration: 300
4
+ duration: 300,
5
+ filler: {
6
+ backgroundColor: var(--color-bg-main-subtle-alt),
7
+ color: var(--color-bg-success)
8
+ }
5
9
  }, $UI.Progress, true)
6
10
 
7
11
  // ----- COMPONENT
8
12
 
9
- _backgroundColor = var(--color-bg-main-subtle-alt)
10
- _fillerColor = var(--color-bg-success)
11
13
  _duration = $this.duration
12
14
 
13
15
  .progress
14
- background-color _backgroundColor
15
16
  overflow hidden
16
17
 
18
+ &.linear
19
+ background-color $this.filler.backgroundColor
20
+
17
21
  .filler
18
22
  height _size
19
- background-color _fillerColor
23
+ background-color $this.filler.color
20
24
 
21
25
  +web()
22
26
  transition width (_duration/1000)s
package/index.tsx CHANGED
@@ -5,6 +5,7 @@ import { themed } from '@startupjs-ui/core'
5
5
  import Div, { type DivProps } from '@startupjs-ui/div'
6
6
  import Span from '@startupjs-ui/span'
7
7
  import Filler from './filler'
8
+ import CircleFiller from './circleFiller'
8
9
  import './index.cssx.styl'
9
10
 
10
11
  export default observer(themed('Progress', Progress))
@@ -38,13 +39,22 @@ function Progress ({
38
39
  shape = 'rounded',
39
40
  width = u(0.5)
40
41
  }: ProgressProps): ReactNode {
41
- const extraStyle = { height: width }
42
+ const isCircular = variant === 'circular'
43
+ const extraStyle = isCircular ? {} : { height: width }
42
44
 
43
45
  return pug`
44
46
  View(style=style)
45
- Div.progress(part='progress' style=extraStyle shape=shape)
47
+ Div.progress(
48
+ part='progress'
49
+ style=extraStyle
50
+ styleName=[variant]
51
+ shape=shape
52
+ )
46
53
  //- To normalize value pass value=Math.min(value, 100)
47
- Filler(part='filler' style=extraStyle value=value)
54
+ if isCircular
55
+ CircleFiller(part='filler' style=extraStyle value=value width=width)
56
+ else
57
+ Filler(part='filler' style=extraStyle value=value)
48
58
  if typeof children === 'string'
49
59
  Span.label= children
50
60
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startupjs-ui/progress",
3
- "version": "0.1.13",
3
+ "version": "0.1.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -9,13 +9,13 @@
9
9
  "type": "module",
10
10
  "dependencies": {
11
11
  "@startupjs-ui/core": "^0.1.11",
12
- "@startupjs-ui/div": "^0.1.13",
13
- "@startupjs-ui/span": "^0.1.13"
12
+ "@startupjs-ui/div": "^0.1.16",
13
+ "@startupjs-ui/span": "^0.1.16"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": "*",
17
17
  "react-native": "*",
18
18
  "startupjs": "*"
19
19
  },
20
- "gitHead": "5cfdccf2bdae3873e968289a3e6b938fad02101a"
20
+ "gitHead": "8efcabc51cd49106c430ce6f74d22679017f0689"
21
21
  }