-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Demo): function values select (#140)
- Loading branch information
1 parent
6321bfa
commit 6ce8cf4
Showing
16 changed files
with
159 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {collapseVerticalTransition, fadeTransition} from '../core/lib/transitions/bootstrap'; | ||
import {getPaginationDefaultConfig, getRatingDefaultConfig} from '@agnos-ui/core'; | ||
|
||
export type PropsValues = keyof typeof propsValuesList; | ||
|
||
const propsValuesList = { | ||
//common | ||
log: {value: (x: any) => console.log(x), label: 'Log'}, | ||
noop: {value: () => {}, label: 'Noop'}, | ||
//transitions | ||
collapse: {value: collapseVerticalTransition, label: 'Collapse'}, | ||
fade: {value: fadeTransition, label: 'Fade'}, | ||
//rating | ||
ratingValueFunction: {value: getRatingDefaultConfig().ariaValueTextFn, label: 'RatingValue'}, | ||
heartsRatingValue: { | ||
value: (rating: number, maxRating: number) => | ||
`${rating} ${rating === 1 ? 'heart' : 'hearts'} out of ${maxRating} ${maxRating === 1 ? 'heart' : 'hearts'}`, | ||
label: 'HeartsRatingValue', | ||
}, | ||
starRatingValue: { | ||
value: (rating: number, maxRating: number) => | ||
`${rating} ${rating === 1 ? 'star' : 'stars'} out of ${maxRating} ${maxRating === 1 ? 'star' : 'stars'}`, | ||
label: 'StarRatingValue', | ||
}, | ||
starIconRating: {value: getRatingDefaultConfig().slotStar, label: 'StarIconRating'}, | ||
heartIconRating: {value: ({fill}: {fill: number}) => String.fromCharCode(fill === 100 ? 9829 : 9825), label: 'HeartIconRating'}, | ||
//pagination | ||
defaultPageFactory: {value: getPaginationDefaultConfig().pagesFactory, label: 'DefaultPageFactory'}, | ||
simpleLabel: {value: getPaginationDefaultConfig().ariaPageLabel, label: 'SimpleLabel'}, | ||
pageLabel: {value: (processPage: number, pageCount: number) => `Page ${processPage} of ${pageCount}`, label: 'PageLabel'}, | ||
slotNumberLabel: {value: getPaginationDefaultConfig().slotNumberLabel, label: 'SlotNumberLabel'}, | ||
}; | ||
|
||
export const getPropValues = (config: Record<string, any>) => { | ||
const configUpdated = {...config}; | ||
for (const [key, value] of Object.entries(configUpdated)) { | ||
if (propsValuesList[value?.value as PropsValues] !== undefined) { | ||
configUpdated[key] = propsValuesList[value.value as PropsValues].value; | ||
} | ||
} | ||
return configUpdated; | ||
}; | ||
|
||
export const getPropValueLabel = (key: PropsValues) => { | ||
return propsValuesList[key as PropsValues].label; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.