@startupjs-ui/progress 0.1.16 → 0.1.19

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.19](https://github.com/startupjs/startupjs-ui/compare/v0.1.18...v0.1.19) (2026-03-17)
7
+
8
+ **Note:** Version bump only for package @startupjs-ui/progress
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.1.18](https://github.com/startupjs/startupjs-ui/compare/v0.1.17...v0.1.18) (2026-02-23)
15
+
16
+
17
+ ### Features
18
+
19
+ * add rounded progress ([#16](https://github.com/startupjs/startupjs-ui/issues/16)) ([d219deb](https://github.com/startupjs/startupjs-ui/commit/d219deb050cd352852d8fad2c09044ead1106bb7))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.1.16](https://github.com/startupjs/startupjs-ui/compare/v0.1.15...v0.1.16) (2026-02-10)
7
26
 
8
27
  **Note:** Version bump only for package @startupjs-ui/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.16",
3
+ "version": "0.1.19",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -8,14 +8,14 @@
8
8
  "types": "index.d.ts",
9
9
  "type": "module",
10
10
  "dependencies": {
11
- "@startupjs-ui/core": "^0.1.11",
12
- "@startupjs-ui/div": "^0.1.16",
13
- "@startupjs-ui/span": "^0.1.16"
11
+ "@startupjs-ui/core": "^0.1.19",
12
+ "@startupjs-ui/div": "^0.1.19",
13
+ "@startupjs-ui/span": "^0.1.19"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": "*",
17
17
  "react-native": "*",
18
18
  "startupjs": "*"
19
19
  },
20
- "gitHead": "9943aa3566d5d80f5b404473906eb3c0611f9ee5"
20
+ "gitHead": "bfcca786dc363f42a09b6eef4feb7ca8139302fc"
21
21
  }