@startupjs-ui/progress 0.1.16 → 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 +11 -0
- package/circleFiller.tsx +73 -0
- package/index.cssx.styl +9 -5
- package/index.tsx +13 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
|
|
6
17
|
## [0.1.16](https://github.com/startupjs/startupjs-ui/compare/v0.1.15...v0.1.16) (2026-02-10)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @startupjs-ui/progress
|
package/circleFiller.tsx
ADDED
|
@@ -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
|
|
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
|
|
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(
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"react-native": "*",
|
|
18
18
|
"startupjs": "*"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "8efcabc51cd49106c430ce6f74d22679017f0689"
|
|
21
21
|
}
|