Skip to content

Commit 49f53b5

Browse files
authored
Merge branch 'main' into fe/bugfix/RI-7634-notifications-main
2 parents 4c64b06 + 723c9a5 commit 49f53b5

File tree

252 files changed

+5002
-2256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+5002
-2256
lines changed

.eslintrc.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
node: true,
77
browser: true,
88
},
9-
extends: ['airbnb-typescript', 'prettier', 'plugin:prettier/recommended'],
9+
extends: ['airbnb-typescript', 'prettier', 'plugin:prettier/recommended', 'plugin:storybook/recommended'],
1010
plugins: ['@typescript-eslint', 'import', 'prettier'],
1111
parser: '@typescript-eslint/parser',
1212
rules: {
@@ -261,9 +261,6 @@ module.exports = {
261261
rules: {
262262
semi: 'off',
263263
'@typescript-eslint/semi': 'off',
264-
'@typescript-eslint/no-unused-vars': 'off',
265-
'@typescript-eslint/no-use-before-define': 'off',
266-
'@typescript-eslint/no-unused-expressions': 'off',
267264
'sonarjs/no-identical-functions': 'off',
268265
'sonarjs/prefer-immediate-return': 'off',
269266
'sonarjs/no-duplicate-string': 'off',
@@ -274,14 +271,10 @@ module.exports = {
274271
'no-underscore-dangle': 'off',
275272
'import/no-duplicates': 'off',
276273
'no-console': 'off',
277-
'prettier/prettier': 'off',
278274
'prefer-destructuring': 'off',
279275
'no-unneeded-ternary': 'off',
280276
'prefer-template': 'off',
281277
'prefer-const': 'off',
282-
'@typescript-eslint/naming-convention': 'off',
283-
'@typescript-eslint/lines-between-class-members': 'off',
284-
'@typescript-eslint/no-shadow': 'off',
285278
// REDUNDANT: These are OFF by default in newer Airbnb config
286279
// 'prefer-arrow-callback': 'off',
287280
// 'no-restricted-syntax': 'off',
@@ -427,7 +420,9 @@ module.exports = {
427420
'node_modules',
428421
'release',
429422
'redisinsight/ui/src/packages/**/icons/*.js*',
423+
'redisinsight/ui/src/packages/**',
430424
'redisinsight/api/report/**',
425+
'redisinsight/api/static/**',
431426
'redisinsight/api/migration/**',
432427
// Config files that don't need linting
433428
'.eslintrc.js',

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ static/
9191
# AI rules
9292
.windsurfrules
9393
.junie/
94+
*storybook.log
95+
storybook-static

.storybook/RootStoryLayout.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React, { FC, PropsWithChildren } from 'react'
2+
import { StoryContext } from '@storybook/react-vite'
3+
4+
export interface Parameters {
5+
storyLayout?: FC<PropsWithChildren<{ storyContext: StoryContext }>>
6+
}
7+
8+
/**
9+
* Note: for use in Storybook preview config
10+
*
11+
* Define parameters.storyLayout as React component, and it will be used as root layout of the story
12+
*/
13+
export const RootStoryLayout = ({
14+
children,
15+
storyContext,
16+
}: Required<PropsWithChildren<{ storyContext: StoryContext }>>) => {
17+
const { storyLayout } = storyContext.parameters
18+
if (!storyLayout) {
19+
return <>{children}</>
20+
}
21+
if (React.isValidElement(storyLayout)) {
22+
// @ts-ignore
23+
return React.cloneElement(storyLayout, { storyContext }, children)
24+
}
25+
26+
const StoryLayout = storyLayout
27+
return <StoryLayout storyContext={storyContext}>{children}</StoryLayout>
28+
}

.storybook/Story.context.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createContext, useContext } from 'react'
2+
import { StoryContext } from '@storybook/react-vite'
3+
4+
const Context = createContext<StoryContext | null>(null)
5+
6+
export const StoryContextProvider = Context.Provider
7+
8+
export const useStoryContext = () => {
9+
const context = useContext(Context)
10+
if (!context)
11+
throw new Error('useStoryContext must be used within StoryContextProvider')
12+
return context
13+
}
14+
15+
export const useStoryParameter = <T>(parameterKey: string): T | undefined =>
16+
useStoryContext().parameters[parameterKey]

.storybook/helpers/styles.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import styled from 'styled-components'
2+
import { Theme } from 'uiSrc/components/base/theme/types'
3+
4+
export const StyledContainer = styled.div`
5+
padding: 50px;
6+
height: max-content;
7+
overflow: hidden;
8+
overflow-y: auto;
9+
background-color: ${({ theme }: { theme: Theme }) =>
10+
theme.semantic.color.background.neutral100};
11+
border: 2px solid
12+
${({ theme }: { theme: Theme }) => theme.semantic.color.border.neutral500};
13+
`

.storybook/main.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { StorybookConfig } from '@storybook/react-vite'
2+
import { mergeConfig } from 'vite'
3+
import vc from './vite.config'
4+
5+
const config: StorybookConfig = {
6+
async viteFinal(inlineConfig) {
7+
// return the customized config
8+
return mergeConfig(inlineConfig, vc)
9+
},
10+
stories: [
11+
'../stories/**/*.mdx',
12+
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
13+
'../redisinsight/ui/src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
14+
'../redisinsight/ui/src/**/*.mdx',
15+
],
16+
addons: [
17+
'@storybook/addon-a11y',
18+
'@storybook/addon-docs',
19+
'@storybook/addon-links',
20+
'@storybook/addon-themes',
21+
],
22+
framework: {
23+
name: '@storybook/react-vite',
24+
options: {},
25+
},
26+
}
27+
export default config

.storybook/preview-head.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script>
2+
window.global = window;
3+
</script>
4+
<style>
5+
:root {
6+
/*
7+
Insert global variables here:
8+
colors, sizes, fonts, etc.
9+
*/
10+
}
11+
12+
body {
13+
min-height: 100vh;
14+
}
15+
16+
.sbdocs-wrapper div:has(>div>.toc-wrapper){
17+
width:14rem;
18+
}
19+
20+
.sbdocs-wrapper div:has(>.toc-wrapper){
21+
width:fit-content;
22+
margin-right:1rem;
23+
}
24+
25+
.sbdocs-wrapper .toc-wrapper .toc-list-item {
26+
padding-block: 5px;
27+
}
28+
29+
.sb-errordisplay pre code {
30+
background-color: transparent;
31+
}
32+
33+
.docblock-argstable [type='checkbox'][role='switch'] {
34+
display: none;
35+
}
36+
37+
pre:has(.docblock-source), pre.prismjs{
38+
max-height: none; /*fix code block scroll*/
39+
}
40+
41+
.docblock-source [data-radix-scroll-area-viewport],
42+
.docs-story + div [data-radix-scroll-area-viewport]{
43+
max-height: 80vh; /*add max height of code block*/
44+
}
45+
46+
</style>

.storybook/preview.tsx

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import React from 'react'
2+
import type { Parameters, Preview } from '@storybook/react-vite'
3+
import { withThemeFromJSXProvider } from '@storybook/addon-themes'
4+
import {
5+
createGlobalStyle,
6+
ThemeProvider as StyledThemeProvider,
7+
} from 'styled-components'
8+
import { CommonStyles, themeDark, themeLight, themeOld } from '@redis-ui/styles'
9+
import 'modern-normalize/modern-normalize.css'
10+
import '@redis-ui/styles/normalized-styles.css'
11+
import '@redis-ui/styles/fonts.css'
12+
import { RootStoryLayout } from './RootStoryLayout'
13+
import { StoryContextProvider } from './Story.context'
14+
import { useStoryContext } from 'storybook/internal/preview-api'
15+
import { TooltipProvider } from '@redis-ui/components'
16+
import { type Theme } from 'uiSrc/components/base/theme/types'
17+
// import { store } from 'uiSrc/utils/test-utils'
18+
import { Provider } from 'react-redux'
19+
import { store } from 'uiSrc/slices/store'
20+
import Router from 'uiSrc/Router'
21+
22+
const parameters: Parameters = {
23+
parameters: {
24+
layout: 'centered',
25+
},
26+
actions: { argTypesRegex: '^on[A-Z].*' },
27+
controls: {
28+
disableSaveFromUI: true,
29+
matchers: {
30+
color: /(background|color)$/i,
31+
date: /Date$/,
32+
},
33+
expanded: true,
34+
sort: 'requiredFirst',
35+
exclude: ['theme'],
36+
},
37+
docs: {
38+
toc: true,
39+
controls: {
40+
sort: 'requiredFirst',
41+
},
42+
},
43+
options: {
44+
storySort: {
45+
method: 'alphabetical',
46+
order: ['Getting Started', 'Playground', '*'],
47+
},
48+
},
49+
}
50+
51+
const GlobalStoryStyles = createGlobalStyle`
52+
.sb-show-main, .docs-story {
53+
background: ${({ theme }: { theme: Theme }) => theme.globals.body.bgColor};
54+
color: ${({ theme }: { theme: Theme }) => theme.globals.body.textColor};
55+
}
56+
`
57+
58+
const preview: Preview = {
59+
parameters,
60+
decorators: [
61+
(Story) => (
62+
<StoryContextProvider value={useStoryContext()}>
63+
<Router>
64+
<Provider store={store}>
65+
<TooltipProvider>
66+
<RootStoryLayout storyContext={useStoryContext()}>
67+
<CommonStyles />
68+
<Story />
69+
</RootStoryLayout>
70+
</TooltipProvider>
71+
</Provider>
72+
</Router>
73+
</StoryContextProvider>
74+
),
75+
withThemeFromJSXProvider({
76+
themes: {
77+
light: themeLight,
78+
dark: themeDark,
79+
obsolete: themeOld,
80+
},
81+
defaultTheme: 'light',
82+
Provider: StyledThemeProvider,
83+
GlobalStyles: GlobalStoryStyles,
84+
}),
85+
],
86+
}
87+
88+
export default preview

.storybook/redis-theme.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { create } from '@storybook/theming/create';
2+
3+
export default create({
4+
base: 'light',
5+
6+
brandTitle: 'Redis UI',
7+
brandUrl: 'https://github.com/redislabsdev/redis-ui',
8+
brandImage: 'logo.svg',
9+
brandTarget: '_blank',
10+
11+
colorPrimary: '#001D2D',
12+
colorSecondary: '#FF4438',
13+
14+
// UI
15+
appBg: '#001D2D',
16+
17+
// Toolbar default and active colors
18+
barBg: '#F0F0F0',
19+
textMutedColor: '#5C707A'
20+
});

.storybook/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"jsx": "react",
5+
"types": ["node", "vite/client"],
6+
"module": "ESNext"
7+
},
8+
"include": [
9+
"./**/*"
10+
]
11+
}

0 commit comments

Comments
 (0)