Skip to content

Commit ad0ef5e

Browse files
committed
refactor(CProgress): move the context outside the component
1 parent b6dc072 commit ad0ef5e

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

packages/coreui-react/src/components/progress/CProgress.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { forwardRef, HTMLAttributes, useContext } from 'react'
22
import PropTypes from 'prop-types'
33
import classNames from 'classnames'
44

5-
import { CProgressStackedContext } from './CProgressStacked'
5+
import { CProgressStackedContext } from './CProgressStackedContext'
66
import { CProgressBar, CProgressBarProps } from './CProgressBar'
77

88
export interface CProgressProps

packages/coreui-react/src/components/progress/CProgressBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import React, { forwardRef, HTMLAttributes, useContext } from 'react'
22
import PropTypes from 'prop-types'
33
import classNames from 'classnames'
44

5-
import { CProgressStackedContext } from './CProgressStacked'
65
import { colorPropType } from '../../props'
76
import type { Colors } from '../../types'
87

8+
import { CProgressStackedContext } from './CProgressStackedContext'
9+
910
export interface CProgressBarProps extends HTMLAttributes<HTMLDivElement> {
1011
/**
1112
* Use to animate the stripes right to left via CSS3 animations.

packages/coreui-react/src/components/progress/CProgressStacked.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import React, { createContext, forwardRef, HTMLAttributes } from 'react'
1+
import React, { forwardRef, HTMLAttributes } from 'react'
22
import PropTypes from 'prop-types'
33
import classNames from 'classnames'
44

5+
import { CProgressStackedContext } from './CProgressStackedContext'
6+
57
export interface CProgressStackedProps extends HTMLAttributes<HTMLDivElement> {
68
/**
79
* A string of all className you want applied to the component.
810
*/
911
className?: string
1012
}
1113

12-
export interface CProgressStackedContextProps {
13-
stacked?: boolean
14-
}
15-
16-
export const CProgressStackedContext = createContext({} as CProgressStackedContextProps)
17-
1814
export const CProgressStacked = forwardRef<HTMLDivElement, CProgressStackedProps>(
1915
({ children, className, ...rest }, ref) => {
2016
return (
@@ -28,7 +24,7 @@ export const CProgressStacked = forwardRef<HTMLDivElement, CProgressStackedProps
2824
</CProgressStackedContext.Provider>
2925
</div>
3026
)
31-
},
27+
}
3228
)
3329

3430
CProgressStacked.propTypes = {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createContext } from 'react'
2+
3+
export interface CProgressStackedContextProps {
4+
stacked?: boolean
5+
}
6+
7+
export const CProgressStackedContext = createContext({} as CProgressStackedContextProps)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy