Skip to content

Commit cccd520

Browse files
feat(admin-ui): revamp Health, License, and Audit Message and Loader components (#2584) (#2620)
* Health page migrated * License page implemented * Gluu Commit Page implemented * code rabbit ai reviews * code rabbit ai reviews * code rabbit ai reviews * code rabbit ai reviews * code rabbit ai reviews * code rabbit ai reviews * code rabbit ai reviews * code rabbit ai reviews
1 parent b545188 commit cccd520

Some content is hidden

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

55 files changed

+1458
-855
lines changed

admin-ui/app/components/GluuButton/GluuButton.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
3030
minHeight,
3131
style,
3232
className,
33+
useOpacityOnHover = false,
34+
hoverOpacity,
3335
onClick,
3436
type = 'button',
3537
title,
@@ -48,6 +50,8 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
4850
const text = textColor ?? themeColors.fontColor
4951
const border = borderColor ?? (isDark ? 'transparent' : themeColors.borderColor)
5052
const hoverBg = isDark ? themeColors.lightBackground : themeColors.borderColor
53+
const keepBgOnHover = useOpacityOnHover && isHovered && !isDisabled
54+
const opacityOnHover = hoverOpacity ?? 0.5
5155

5256
return {
5357
display: 'inline-flex',
@@ -62,18 +66,20 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
6266
minHeight: minHeight ?? sizeConfig.minHeight,
6367
borderRadius: borderRadius ?? '6px',
6468
border: `1px solid ${border}`,
65-
backgroundColor: outlined
66-
? isHovered && !isDisabled
67-
? `${bg}15`
68-
: 'transparent'
69-
: isHovered && !isDisabled
70-
? hoverBg
71-
: bg,
69+
backgroundColor: keepBgOnHover
70+
? bg
71+
: outlined
72+
? isHovered && !isDisabled
73+
? `${bg}15`
74+
: 'transparent'
75+
: isHovered && !isDisabled
76+
? hoverBg
77+
: bg,
7278
color: outlined ? themeColors.fontColor : text,
7379
cursor: isDisabled ? 'not-allowed' : 'pointer',
74-
opacity: isDisabled ? 0.65 : 1,
80+
opacity: isDisabled ? 0.65 : keepBgOnHover ? opacityOnHover : 1,
7581
width: block ? '100%' : 'auto',
76-
transition: 'background-color 0.15s ease-in-out',
82+
transition: 'background-color 0.15s ease-in-out, opacity 0.15s ease-in-out',
7783
...style,
7884
}
7985
}, [
@@ -92,6 +98,8 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
9298
fontWeight,
9399
padding,
94100
minHeight,
101+
useOpacityOnHover,
102+
hoverOpacity,
95103
style,
96104
])
97105

admin-ui/app/components/GluuButton/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export interface GluuButtonProps {
2121
minHeight?: string | number
2222
style?: CSSProperties
2323
className?: string
24+
useOpacityOnHover?: boolean
25+
hoverOpacity?: number
2426
onClick?: () => void
2527
type?: 'button' | 'submit' | 'reset'
2628
title?: string
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { makeStyles } from 'tss-react/mui'
2+
import { SPACING } from '@/constants'
3+
4+
interface GluuPageContentStyleParams {
5+
withVerticalPadding: boolean
6+
maxWidth?: number
7+
background: string
8+
}
9+
10+
export const useStyles = makeStyles<GluuPageContentStyleParams>()(
11+
(_, { withVerticalPadding, maxWidth, background }) => ({
12+
root: {
13+
maxWidth: '100vw',
14+
width: '100%',
15+
padding: withVerticalPadding ? `${SPACING.PAGE}px` : `0 ${SPACING.PAGE}px`,
16+
boxSizing: 'border-box',
17+
backgroundColor: background,
18+
},
19+
wrapper: {
20+
width: '100%',
21+
maxWidth: maxWidth ?? '100%',
22+
display: 'flex',
23+
justifyContent: 'center',
24+
flexDirection: 'column',
25+
},
26+
}),
27+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { memo, useContext, useMemo } from 'react'
2+
import { ThemeContext } from '@/context/theme/themeContext'
3+
import getThemeColor from '@/context/theme/config'
4+
import { DEFAULT_THEME } from '@/context/theme/constants'
5+
import customColors from '@/customColors'
6+
import { useStyles } from './GluuPageContent.style'
7+
import type { GluuPageContentProps } from './types'
8+
9+
const GluuPageContent: React.FC<GluuPageContentProps> = memo(
10+
({ children, className, withVerticalPadding = true, maxWidth, backgroundColor }) => {
11+
const themeContext = useContext(ThemeContext)
12+
const currentTheme = useMemo(
13+
() => themeContext?.state.theme || DEFAULT_THEME,
14+
[themeContext?.state.theme],
15+
)
16+
const themeColors = useMemo(() => getThemeColor(currentTheme), [currentTheme])
17+
const background = backgroundColor ?? themeColors?.background ?? customColors.lightBackground
18+
19+
const { classes } = useStyles({
20+
withVerticalPadding,
21+
maxWidth,
22+
background,
23+
})
24+
25+
return (
26+
<div className={`${classes.root} ${className ?? ''}`.trim()}>
27+
{maxWidth ? <div className={classes.wrapper}>{children}</div> : children}
28+
</div>
29+
)
30+
},
31+
)
32+
33+
GluuPageContent.displayName = 'GluuPageContent'
34+
35+
export default GluuPageContent
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as GluuPageContent } from './GluuPageContent'
2+
export type { GluuPageContentProps } from './types'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { ReactNode } from 'react'
2+
3+
export type GluuPageContentProps = {
4+
children: ReactNode
5+
className?: string
6+
withVerticalPadding?: boolean
7+
maxWidth?: number
8+
backgroundColor?: string
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { makeStyles } from 'tss-react/mui'
2+
import customColors, { hexToRgb } from '@/customColors'
3+
4+
const TRACK_COLOR_DARK = `rgba(${hexToRgb(customColors.white)}, 0.12)`
5+
const TRACK_COLOR_LIGHT = `rgba(${hexToRgb(customColors.black)}, 0.08)`
6+
7+
interface GluuSpinnerStyleParams {
8+
size: number
9+
isDark: boolean
10+
}
11+
12+
const useStyles = makeStyles<GluuSpinnerStyleParams>()((_, { size, isDark }) => ({
13+
'@keyframes spin': {
14+
'0%': { transform: 'rotate(0deg)' },
15+
'100%': { transform: 'rotate(360deg)' },
16+
},
17+
'spinner': {
18+
display: 'block',
19+
width: size,
20+
height: size,
21+
borderRadius: '50%',
22+
border: `${Math.max(3, Math.floor(size / 12))}px solid ${
23+
isDark ? TRACK_COLOR_DARK : TRACK_COLOR_LIGHT
24+
}`,
25+
borderTopColor: customColors.logo,
26+
animation: 'spin 0.8s linear infinite',
27+
flexShrink: 0,
28+
},
29+
}))
30+
31+
export { useStyles }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { useContext } from 'react'
2+
import { ThemeContext } from '@/context/theme/themeContext'
3+
import { THEME_DARK, DEFAULT_THEME } from '@/context/theme/constants'
4+
import { useStyles } from './GluuSpinner.style'
5+
6+
interface GluuSpinnerProps {
7+
'size'?: number
8+
'isDark'?: boolean
9+
'aria-label'?: string
10+
}
11+
12+
const GluuSpinner = React.memo<GluuSpinnerProps>(
13+
({ size = 48, 'isDark': isDarkProp, 'aria-label': ariaLabel = 'Loading' }) => {
14+
const themeContext = useContext(ThemeContext)
15+
const currentTheme = themeContext?.state.theme || DEFAULT_THEME
16+
const isDark = isDarkProp ?? currentTheme === THEME_DARK
17+
18+
const { classes } = useStyles({ size, isDark })
19+
20+
return <output className={classes.spinner} aria-label={ariaLabel} aria-live="polite" />
21+
},
22+
)
23+
24+
GluuSpinner.displayName = 'GluuSpinner'
25+
26+
export default GluuSpinner
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as GluuSpinner } from './GluuSpinner'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type { StatusBadgeProps, StatusBadgeTheme, ServiceStatusValue } from './types'

0 commit comments

Comments
 (0)