diff --git a/redisinsight/ui/src/components/base/layout/empty-prompt/RiEmptyPrompt.tsx b/redisinsight/ui/src/components/base/layout/empty-prompt/RiEmptyPrompt.tsx new file mode 100644 index 0000000000..26205acc6b --- /dev/null +++ b/redisinsight/ui/src/components/base/layout/empty-prompt/RiEmptyPrompt.tsx @@ -0,0 +1,41 @@ +import React, { HTMLAttributes } from 'react' +import styled from 'styled-components' +import { useTheme } from '@redis-ui/styles' +import { Spacer } from '../spacer' + +interface RiEmptyPromptProps extends Omit, 'title'> { + body?: React.ReactNode + title?: React.ReactNode + icon?: React.ReactNode +} + +const StyledEmptyPrompt = styled.div` + max-width: 36em; + text-align: center; + padding: 24px; + margin: auto; +` + +const RiEmptyPrompt = ({ body, title, icon, ...rest }: RiEmptyPromptProps) => { + const theme = useTheme() + + return ( + {icon} + {title && ( + <> + + {title} + + )} + {body && ( + <> + + {body} + + )} + + ) +} + + +export default RiEmptyPrompt diff --git a/redisinsight/ui/src/components/base/layout/index.ts b/redisinsight/ui/src/components/base/layout/index.ts index 6b8676cf8c..2d630f0614 100644 --- a/redisinsight/ui/src/components/base/layout/index.ts +++ b/redisinsight/ui/src/components/base/layout/index.ts @@ -3,7 +3,7 @@ import LoadingContent from './loading-content/LoadingContent' import ResizableContainer from './resize/container/ResizableContainer' import ResizablePanel from './resize/panel/ResizablePanel' import ResizablePanelHandle from './resize/handle/ResizablePanelHandle' - +import RiEmptyPrompt from './empty-prompt/RiEmptyPrompt' export * from './card' export * from './horizontal-spacer' @@ -14,4 +14,5 @@ export { ResizablePanel, ResizableContainer, ResizablePanelHandle, + RiEmptyPrompt, } diff --git a/redisinsight/ui/src/components/base/layout/spacer/spacer.styles.ts b/redisinsight/ui/src/components/base/layout/spacer/spacer.styles.ts index 54d42335b2..a36a1dad61 100644 --- a/redisinsight/ui/src/components/base/layout/spacer/spacer.styles.ts +++ b/redisinsight/ui/src/components/base/layout/spacer/spacer.styles.ts @@ -1,13 +1,20 @@ import { HTMLAttributes, ReactNode } from 'react' import styled from 'styled-components' import { CommonProps } from 'uiSrc/components/base/theme/types' +import { theme } from 'uiSrc/components/base/theme' export const SpacerSizes = ['xs', 's', 'm', 'l', 'xl', 'xxl'] as const export type SpacerSize = (typeof SpacerSizes)[number] + +// Extract only the spaceXXX keys from the theme +export type ThemeSpacingKey = Extract +// Allow direct theme spacing values +export type ThemeSpacingValue = typeof theme.semantic.core.space[ThemeSpacingKey] + export type SpacerProps = CommonProps & HTMLAttributes & { children?: ReactNode - size?: SpacerSize + size?: SpacerSize | ThemeSpacingKey | ThemeSpacingValue } export const spacerStyles = { @@ -20,7 +27,26 @@ export const spacerStyles = { xxl: 'var(--size-xxl)', } +const isThemeSpacingKey = ( + size: SpacerSize | ThemeSpacingKey | ThemeSpacingValue +): size is ThemeSpacingKey => typeof size === 'string' && size in theme.semantic.core.space + +const getSpacingValue = ( + size: SpacerSize | ThemeSpacingKey | ThemeSpacingValue, +): string => { + const themeSpacingValues = Object.values(theme.semantic.core.space) + if (typeof size === 'string' && themeSpacingValues.includes(size)) { + return size + } + + if (isThemeSpacingKey(size)) { + return theme?.semantic?.core?.space?.[size] || '0' + } + + return spacerStyles[size as SpacerSize] +} + export const StyledSpacer = styled.div` flex-shrink: 0; - height: ${({ size = 'l' }) => spacerStyles[size]}; + height: ${({ size = 'l' }) => getSpacingValue(size)}; ` diff --git a/redisinsight/ui/src/components/base/layout/spacer/spacer.tsx b/redisinsight/ui/src/components/base/layout/spacer/spacer.tsx index b811b91abd..0f820b3039 100644 --- a/redisinsight/ui/src/components/base/layout/spacer/spacer.tsx +++ b/redisinsight/ui/src/components/base/layout/spacer/spacer.tsx @@ -1,5 +1,6 @@ import React from 'react' import cx from 'classnames' +import { useTheme } from '@redis-ui/styles' import { SpacerProps, StyledSpacer, @@ -9,17 +10,21 @@ import { * A simple spacer component that can be used to add vertical spacing between * other components. The size of the spacer can be specified using the `size` * prop, which can be one of the following values: - * - 'xs' = 4px - * - 's' = 8px - * - 'm' = 12px - * - 'l' = 16px - * - 'xl' = 24px - * - 'xxl' = 32px. + * - Legacy sizes: 'xs' = 4px, 's' = 8px, 'm' = 12px, 'l' = 16px, 'xl' = 24px, 'xxl' = 32px + * - Theme spacing sizes: Any key from theme.semantic.core.space (e.g., 'space000', 'space010', + * 'space025', 'space050', 'space100', 'space150', 'space200', 'space250', 'space300', + * 'space400', 'space500', 'space550', 'space600', 'space800', etc.) + * + * The theme spacing tokens are dynamically extracted from the theme, ensuring consistency + * and automatic updates when the theme changes. * * The default value for `size` is 'l'. */ -export const Spacer = ({ className, children, ...rest }: SpacerProps) => ( - +export const Spacer = ({ className, children, ...rest }: SpacerProps) => { + const theme = useTheme() + return ( + {children} ) +} \ No newline at end of file diff --git a/redisinsight/ui/src/components/page-placeholder/PagePlaceholder.tsx b/redisinsight/ui/src/components/page-placeholder/PagePlaceholder.tsx index 2d1a884197..10dd4ae605 100644 --- a/redisinsight/ui/src/components/page-placeholder/PagePlaceholder.tsx +++ b/redisinsight/ui/src/components/page-placeholder/PagePlaceholder.tsx @@ -1,18 +1,18 @@ import React from 'react' -import { EuiEmptyPrompt } from '@elastic/eui' + import LogoIcon from 'uiSrc/assets/img/logo_small.svg' import { getConfig } from 'uiSrc/config' import { RiLoadingLogo } from 'uiSrc/components/base/display' +import { RiEmptyPrompt } from 'uiSrc/components/base/layout' const riConfig = getConfig() const PagePlaceholder = () => ( <> {riConfig.app.env !== 'development' && ( - } - titleSize="s" /> )} diff --git a/redisinsight/ui/src/components/side-panels/panels/enablement-area/EnablementArea/components/EmptyPrompt/EmptyPrompt.tsx b/redisinsight/ui/src/components/side-panels/panels/enablement-area/EnablementArea/components/EmptyPrompt/EmptyPrompt.tsx index d054a96fa4..73e8b82fdd 100644 --- a/redisinsight/ui/src/components/side-panels/panels/enablement-area/EnablementArea/components/EmptyPrompt/EmptyPrompt.tsx +++ b/redisinsight/ui/src/components/side-panels/panels/enablement-area/EnablementArea/components/EmptyPrompt/EmptyPrompt.tsx @@ -1,14 +1,14 @@ import React from 'react' -import { EuiEmptyPrompt } from '@elastic/eui' import { EXTERNAL_LINKS } from 'uiSrc/constants/links' import { RiIcon } from 'uiSrc/components/base/icons/RiIcon' import { Link } from 'uiSrc/components/base/link/Link' +import { RiEmptyPrompt } from 'uiSrc/components/base/layout' import styles from './styles.module.scss' const EmptyPrompt = () => (
- } title={

No information to display

}