Skip to content

Commit 478ed3f

Browse files
refactor: rename classNameBuilder utils from use* -> get* because prefix 'use' should only be used for hooks
1 parent 80a60c9 commit 478ed3f

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

src/lib/classNameBuilders.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import { numberToWord } from './numberToWord'
1919
* <Label tag />
2020
* <div class="ui tag label"></div>
2121
*/
22-
export const useKeyOnly = (val, key) => val && key
22+
export const getKeyOnly = (val, key) => val && key
23+
24+
/**
25+
* @deprecated
26+
*/
27+
export const useKeyOnly = getKeyOnly
2328

2429
/**
2530
* Props that require both a key and value to create a className.
@@ -30,7 +35,12 @@ export const useKeyOnly = (val, key) => val && key
3035
* <Label corner='left' />
3136
* <div class="ui left corner label"></div>
3237
*/
33-
export const useValueAndKey = (val, key) => val && val !== true && `${val} ${key}`
38+
export const getValueAndKey = (val, key) => val && val !== true && `${val} ${key}`
39+
40+
/**
41+
* @deprecated
42+
*/
43+
export const useValueAndKey = getValueAndKey
3444

3545
/**
3646
* Props whose key will be used in className, or value and key.
@@ -45,7 +55,12 @@ export const useValueAndKey = (val, key) => val && val !== true && `${val} ${key
4555
* <Label pointing='left' />
4656
* <div class="ui left pointing label"></div>
4757
*/
48-
export const useKeyOrValueAndKey = (val, key) => val && (val === true ? key : `${val} ${key}`)
58+
export const getKeyOrValueAndKey = (val, key) => val && (val === true ? key : `${val} ${key}`)
59+
60+
/**
61+
* @deprecated
62+
*/
63+
export const useKeyOrValueAndKey = getKeyOrValueAndKey
4964

5065
//
5166
// Prop to className exceptions
@@ -63,7 +78,7 @@ export const useKeyOrValueAndKey = (val, key) => val && (val === true ? key : `$
6378
* <div class="mobile only row"></div>
6479
* <div class="mobile only tablet only row"></div>
6580
*/
66-
export const useMultipleProp = (val, key) => {
81+
export const getMultipleProp = (val, key) => {
6782
if (!val || val === true) return null
6883

6984
return val
@@ -74,6 +89,11 @@ export const useMultipleProp = (val, key) => {
7489
.join(' ')
7590
}
7691

92+
/**
93+
* @deprecated
94+
*/
95+
export const useMultipleProp = getMultipleProp
96+
7797
/**
7898
* The "textAlign" prop follows the useValueAndKey except when the value is "justified'.
7999
* In this case, only the class "justified" is used, ignoring the "aligned" class.
@@ -87,8 +107,13 @@ export const useMultipleProp = (val, key) => {
87107
* <Container textAlign='left' />
88108
* <div class="ui left aligned container"></div>
89109
*/
90-
export const useTextAlignProp = (val) =>
91-
val === 'justified' ? 'justified' : useValueAndKey(val, 'aligned')
110+
export const getTextAlignProp = (val) =>
111+
val === 'justified' ? 'justified' : getValueAndKey(val, 'aligned')
112+
113+
/**
114+
* @deprecated
115+
*/
116+
export const useTextAlignProp = getTextAlignProp
92117

93118
/**
94119
* The "verticalAlign" prop follows the useValueAndKey.
@@ -99,7 +124,12 @@ export const useTextAlignProp = (val) =>
99124
* <Grid verticalAlign='middle' />
100125
* <div class="ui middle aligned grid"></div>
101126
*/
102-
export const useVerticalAlignProp = (val) => useValueAndKey(val, 'aligned')
127+
export const getVerticalAlignProp = (val) => getValueAndKey(val, 'aligned')
128+
129+
/**
130+
* @deprecated
131+
*/
132+
export const useVerticalAlignProp = getVerticalAlignProp
103133

104134
/**
105135
* Create "X", "X wide" and "equal width" classNames.
@@ -122,7 +152,7 @@ export const useVerticalAlignProp = (val) => useValueAndKey(val, 'aligned')
122152
* <Grid columns={4} />
123153
* <div class="ui four column grid"></div>
124154
*/
125-
export const useWidthProp = (val, widthClass = '', canEqual = false) => {
155+
export const getWidthProp = (val, widthClass = '', canEqual = false) => {
126156
if (canEqual && val === 'equal') {
127157
return 'equal width'
128158
}
@@ -132,3 +162,8 @@ export const useWidthProp = (val, widthClass = '', canEqual = false) => {
132162
}
133163
return numberToWord(val)
134164
}
165+
166+
/**
167+
* @deprecated
168+
*/
169+
export const useWidthProp = getWidthProp

0 commit comments

Comments
 (0)