Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/progress/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ no-indicator.vue
height.vue
processing.vue
gradient.vue
rtl-debug.vue
```

## API
Expand Down
92 changes: 92 additions & 0 deletions src/progress/demos/enUS/rtl-debug.demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<markdown>
# RTL Debug
</markdown>

<script lang="ts" setup>
import { unstableProgressRtl } from 'naive-ui'
import { ref } from 'vue'

const rtlEnabled = ref(false)
const rtlStyles = [unstableProgressRtl]
</script>

<template>
<n-space vertical>
<n-space><n-switch v-model:value="rtlEnabled" />RTL</n-space>
<n-config-provider :rtl="rtlEnabled ? rtlStyles : undefined">
<n-space vertical>
<!-- Line Progress -->
<n-h4>Line Progress</n-h4>
<n-progress type="line" :percentage="50" />
<n-progress type="line" :percentage="75" status="warning" />
<n-progress type="line" :percentage="100" status="success" />
<n-progress type="line" :percentage="30" status="error" />
<!-- Line Progress with inside indicator -->
<n-progress
type="line"
:percentage="60"
indicator-placement="inside"
:height="24"
/>
<!-- Processing Progress -->
<n-h4>Processing Progress</n-h4>
<n-progress type="line" :percentage="60" processing />
<n-progress
type="line"
:percentage="75"
indicator-placement="inside"
:height="20"
processing
/>
<!-- Circle Progress -->
<n-h4>Circle Progress</n-h4>
<n-space>
<n-progress type="circle" :percentage="25" />
<n-progress type="circle" :percentage="50" status="warning" />
<n-progress type="circle" :percentage="75" status="success" />
<n-progress type="circle" :percentage="100" status="error" />
</n-space>
<!-- Dashboard Progress -->
<n-h4>Dashboard Progress</n-h4>
<n-space>
<n-progress type="dashboard" :percentage="25" />
<n-progress type="dashboard" :percentage="50" status="warning" />
<n-progress type="dashboard" :percentage="75" status="success" />
</n-space>
<!-- Multiple Circle Progress -->
<n-h4>Multiple Circle Progress</n-h4>
<n-progress
type="multiple-circle"
:percentage="[25, 50, 75]"
:stroke-width="6"
/>
<!-- Gradient Progress -->
<n-h4>Gradient Progress</n-h4>
<n-progress
type="line"
:percentage="60"
:color="{ stops: ['#ff6b6b', '#4ecdc4'] }"
/>
<n-progress
type="circle"
:percentage="70"
:color="{ stops: ['#667eea', '#764ba2'] }"
/>
<!-- Custom indicators -->
<n-h4>Custom Content</n-h4>
<n-progress type="line" :percentage="85">
<n-text style="color: rgb(24, 127, 231)">
Custom Text
</n-text>
</n-progress>
<n-progress type="circle" :percentage="65">
<n-icon size="40" color="green">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" />
</svg>
</n-icon>
</n-progress>
</n-space>
</n-config-provider>
</n-space>
</template>
15 changes: 10 additions & 5 deletions src/progress/src/Progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
h,
type PropType
} from 'vue'
import { useConfig, useTheme, useThemeClass } from '../../_mixins'
import { useConfig, useRtl, useTheme, useThemeClass } from '../../_mixins'
import { createKey, type ExtractPublicPropTypes } from '../../_utils'
import { progressLight } from '../styles'
import Circle from './Circle'
Expand Down Expand Up @@ -92,7 +92,8 @@ export default defineComponent({
}
return undefined
})
const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props)
const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef }
= useConfig(props)
const themeRef = useTheme(
'Progress',
'-progress',
Expand Down Expand Up @@ -138,6 +139,7 @@ export default defineComponent({
'--n-text-color-line-outer': textColorLineOuter
}
})
const rtlEnabledRef = useRtl('Progress', mergedRtlRef, mergedClsPrefixRef)
const themeClassHandle = inlineThemeDisabled
? useThemeClass(
'progress',
Expand All @@ -152,7 +154,8 @@ export default defineComponent({
gapDeg,
cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
themeClass: themeClassHandle?.themeClass,
onRender: themeClassHandle?.onRender
onRender: themeClassHandle?.onRender,
rtlEnabled: rtlEnabledRef
}
},
render() {
Expand Down Expand Up @@ -181,7 +184,8 @@ export default defineComponent({
gapOffsetDegree,
themeClass,
$slots,
onRender
onRender,
rtlEnabled
} = this
onRender?.()
return (
Expand All @@ -190,7 +194,8 @@ export default defineComponent({
themeClass,
`${mergedClsPrefix}-progress`,
`${mergedClsPrefix}-progress--${type}`,
`${mergedClsPrefix}-progress--${status}`
`${mergedClsPrefix}-progress--${status}`,
rtlEnabled && `${mergedClsPrefix}-progress--rtl`
]}
style={cssVars as CSSProperties}
aria-valuemax={100}
Expand Down
103 changes: 103 additions & 0 deletions src/progress/src/styles/rtl.cssr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { c, cB, cM } from '../../../_utils/cssr'

export default c([
cB('progress', [
cM('rtl', `
direction: rtl;
`, [
cM('line', [
cB('progress-content', [
cB('progress-graph', [
cB('progress-graph-line', [
cB('progress-graph-line-rail', [
cB('progress-graph-line-fill', `
transform-origin: right center;
`, [
cM('processing', [
c('&::after', `
content: "";
background-image: var(--n-line-bg-processing);
animation: progress-processing-animation-rtl 2s var(--n-bezier) infinite;
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 100%;
`)
])
])
])
])
])
])
]),
cB('progress-custom-content', {
marginLeft: 0,
marginRight: '14px'
}),
cB('progress-icon', `
padding-left: 0;
`, [
cM('as-text', `
padding-left: 0;
padding-right: 4px;
`)
])
]),
cM('circle, dashboard', [
cB('progress-graph', [
cB('progress-graph-circle', `
transform: scaleX(-1);
`)
]),
cB('progress-text', `
direction: ltr;
`),
cB('progress-custom-content', `
direction: ltr;
`),
cB('progress-icon', `
direction: ltr;
`)
]),
cM('multiple-circle', [
cB('progress-graph', [
cB('progress-graph-circle', `
transform: scaleX(-1);
`)
]),
cB('progress-text', `
direction: ltr;
`),
cB('progress-custom-content', `
direction: ltr;
`)
])
]),
c('@keyframes progress-processing-animation-rtl', `
0% {
position: absolute;
right: 0;
top: 0;
bottom: 0;
left: 100%;
opacity: 1;
}
66% {
position: absolute;
right: 0;
top: 0;
bottom: 0;
left: 0;
opacity: 0;
}
100% {
position: absolute;
right: 0;
top: 0;
bottom: 0;
left: 0;
opacity: 0;
}
`)
])
1 change: 1 addition & 0 deletions src/progress/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as progressDark } from './dark'
export { default as progressLight } from './light'
export type { ProgressTheme, ProgressThemeVars } from './light'
export { progressRtl } from './rtl'
8 changes: 8 additions & 0 deletions src/progress/styles/rtl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { RtlItem } from '../../config-provider/src/internal-interface'
import rtlStyle from '../src/styles/rtl.cssr'

export const progressRtl: RtlItem = {
name: 'Progress',
style: rtlStyle,
peers: []
}
5 changes: 4 additions & 1 deletion src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export {
export { popconfirmDark } from './popconfirm/styles'
export { popoverDark, popoverRtl as unstablePopoverRtl } from './popover/styles'
export { popselectDark } from './popselect/styles'
export { progressDark } from './progress/styles'
export {
progressDark,
progressRtl as unstableProgressRtl
} from './progress/styles'
export { radioDark, radioRtl as unstableRadioRtl } from './radio/styles'
export { rateDark } from './rate/styles'
export { resultDark } from './result/styles'
Expand Down
1 change: 0 additions & 1 deletion volar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ declare module 'vue' {
NGi: (typeof import('naive-ui'))['NGi']
NGrid: (typeof import('naive-ui'))['NGrid']
NGridItem: (typeof import('naive-ui'))['NGridItem']
NColorIndicator: (typeof import('naive-ui'))['NColorIndicator']
NHeatmap: (typeof import('naive-ui'))['NHeatmap']
NHighlight: (typeof import('naive-ui'))['NHighlight']
NIcon: (typeof import('naive-ui'))['NIcon']
Expand Down