@chakra-ui/react#StylesProvider TypeScript Examples
The following examples show how to use
@chakra-ui/react#StylesProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactSelectCustomization.tsx From ke with MIT License | 6 votes |
Control = <OptionType, IsMulti extends boolean = false>({ innerRef, innerProps, isFocused, isDisabled, children, getStyles, ...props }: ControlProps<OptionType, IsMulti>): JSX.Element => { const styles = useMultiStyleConfig('SelectWidget', props) return ( <StylesProvider value={styles}> <Flex data-test-id="control" css={getStyles('control', props)} ref={innerRef} sx={{ ...styles.control, overflow: 'hidden', }} {...innerProps} {...(isFocused && { 'data-focus': true })} {...(isDisabled && { disabled: true })} > {children} </Flex> </StylesProvider> ) }
Example #2
Source File: LinkWidget.tsx From ke with MIT License | 5 votes |
LinkWidget = (props: LinkWidgetProps): JSX.Element => {
const { name, mainDetailObject, href, helpText, style, containerStore, target = '_blank', linkProps } = props
const context = containerStore.getState()
const { content, widgetDescription } = useWidgetInitialization({ ...props, context })
const linkHref = getWidgetContent(name, mainDetailObject, href, context)
const styles = useMultiStyleConfig('LinkWidget', props)
const handleClick = (): void => {
pushAnalytics({
eventName: EventNameEnum.LINK_CLICK,
widgetType: WidgetTypeEnum.ACTION,
value: linkHref,
objectForAnalytics: mainDetailObject,
...props,
})
}
const { getDataTestId } = useCreateTestId()
return (
<StylesProvider value={styles}>
<StyledWidgetWrapper
name={name}
style={style}
helpText={helpText || ''}
description={widgetDescription}
{...getDataTestId(props)}
>
<>
{linkHref ? (
<Link target={target} href={linkHref} onClick={() => handleClick()} sx={styles.control} {...linkProps}>
{content || 'Ссылка'}
</Link>
) : (
'-'
)}
</>
</StyledWidgetWrapper>
</StylesProvider>
)
}
Example #3
Source File: ReadOnlyWidget.tsx From ke with MIT License | 5 votes |
ReadOnlyWidget = (props: ReadOnlyWidgetProps): JSX.Element => {
const {
containerStore,
style,
helpText,
useClipboard,
copyValue,
notifier,
name,
innerStyle,
containerProps,
labelContainerProps,
className,
widgetClassName,
isHtmlString,
} = props
const { content, isRequired, widgetDescription } = useWidgetInitialization({
...props,
context: containerStore.getState(),
})
const styles = useMultiStyleConfig('ReadOnlyWidget', props)
const controlStyles = { ...(styles.control || {}), ...(innerStyle || {}) }
const { getDataTestId } = useCreateTestId()
const isHtmlContent = getAccessor(isHtmlString) && typeof content === 'string'
return (
<StylesProvider value={styles}>
<StyledWidgetWrapper
className={className}
name={name}
style={style}
helpText={helpText}
description={widgetDescription}
useClipboard={useClipboard}
copyValue={getCopyHandler(content, copyValue)}
notifier={notifier}
required={isRequired}
containerProps={containerProps}
labelContainerProps={labelContainerProps}
{...getDataTestId(props)}
>
<EmptyText
as={isHtmlContent ? 'div' : undefined}
sx={controlStyles}
className={widgetClassName}
dangerouslySetInnerHTML={isHtmlContent ? { __html: content } : undefined}
>
{isHtmlContent ? undefined : content}
</EmptyText>
</StyledWidgetWrapper>
</StylesProvider>
)
}