Skip to content

Commit

Permalink
LinkedHubs - visual update after review
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikMatiasko committed Apr 24, 2024
1 parent 061cace commit 6f186a6
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^4.9.5",
"units-converter": "^1.0.3",
"usehooks-ts": "^3.1.0",
"vm-browserify": "^1.1.2"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/common/hooks/index.js → src/common/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './useWindowDimensions'
export * from './useDebounce'
export * from './usePersistentState'
export * from './useCaData'
export * from './useDocumentTitle'
8 changes: 4 additions & 4 deletions src/common/hooks/use-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useForm as useFormLib } from 'react-hook-form'
import { useCallback, useContext, useEffect } from 'react'
import isFunction from 'lodash/isFunction'
import cloneDeep from 'lodash/cloneDeep'
import set from 'lodash/set'
import { zodResolver } from '@hookform/resolvers/zod'

import { setProperty } from '../../components/Atomic/_utils/utils'
import { FormContext } from '../context/FormContext'

type UseFormOptionsType = {
Expand Down Expand Up @@ -42,10 +42,10 @@ export function useForm<TFieldValues extends FieldValues = FieldValues>(options:

if (asArray) {
// @ts-ignore
copy[field] = fieldValue
updateData(copy)

updateData(set(copy, field, fieldValue))
} else {
updateData(setProperty(copy, field, fieldValue))
updateData(set(copy, field, fieldValue))
}
},
[data, updateData]
Expand Down
29 changes: 29 additions & 0 deletions src/common/hooks/useDocumentTitle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useRef } from 'react'

import { useIsomorphicLayoutEffect, useUnmount } from 'usehooks-ts'

type UseDocumentTitleOptions = {
preserveTitleOnUnmount?: boolean
}

export function useDocumentTitle(title: string, options: UseDocumentTitleOptions = {}): void {
const { preserveTitleOnUnmount = true } = options
const defaultTitle = useRef<string | null>(null)

useIsomorphicLayoutEffect(() => {
defaultTitle.current = window.document.title
}, [])

useIsomorphicLayoutEffect(() => {
if (title) {
const titleSuffix = document.body.getAttribute('data-plgd-title-suffix')
window.document.title = titleSuffix ? `${title} | ${titleSuffix}` : title
}
}, [title])

useUnmount(() => {
if (!preserveTitleOnUnmount && defaultTitle.current) {
window.document.title = defaultTitle.current
}
})
}
13 changes: 8 additions & 5 deletions src/components/Atomic/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React, { forwardRef } from 'react'
import { Helmet } from 'react-helmet'

import { Props, defaultProps } from './PageLayout.types'
import * as styles from './PageLayout.styles'
import Headline from '../Headline'
import PageLoader from '../PageLoader'
import ConditionalWrapper from '../ConditionalWrapper'
import { useDocumentTitle } from '../../../common/hooks'

const PageLayout = forwardRef<HTMLDivElement, Props>((props, ref) => {
const { children, dataTestId, headlineStatusTag, title, header, headerBorder, footer, loading, collapsed, xPadding } = { ...defaultProps, ...props }
const { children, dataTestId, headlineStatusTag, title, header, headerBorder, footer, loading, collapsed, xPadding } = {
...defaultProps,
...props,
}

useDocumentTitle(title || '')

return (
<div css={styles.pageLayout} ref={ref}>
<Helmet>
<title>{title}</title>
</Helmet>
<div css={styles.top}>
<PageLoader className='auth-loader' collapsed={collapsed} loading={loading} />
<div css={[styles.header, styles.padding, headerBorder && styles.headerBorder]}>
Expand Down
6 changes: 6 additions & 0 deletions src/components/Atomic/_theme/siemens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ const theme = {
description: {
color: colorsSiemens.neutral500,
},
expander: {
color: colorsSiemens.neutral500,
hover: {
color: colorsSiemens.primary,
},
},
groupHeadline: {
color: colorsSiemens.primary,
},
Expand Down
6 changes: 6 additions & 0 deletions src/components/Atomic/_theme/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,12 @@ export const getThemeTemplate = (colors: any, logoProps: LogoType) => ({
description: {
color: colors.neutral900,
},
expander: {
color: colors.neutral500,
hover: {
color: colors.primary,
},
},
groupHeadline: {
color: colors.primaryDarken,
},
Expand Down
21 changes: 16 additions & 5 deletions src/components/Organisms/CaPool/CaPool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@ const CaPool: FC<Props> = (props) => {
{
Header: '',
accessor: 'name',
Cell: ({ value }: { value: string | number }) => (
<span className='no-wrap-text' style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
{typeof value === 'string' ? value.replace(CA_BASE64_PREFIX, '') : value}
</span>
),
Cell: ({ value }: { value: string | number }) => {
if (isFunction(onView)) {
return (
<a href='#' onClick={(e) => onView(value)}>
<span className='no-wrap-text' style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
{value}
</span>
</a>
)
}
return (
<span className='no-wrap-text' style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
{typeof value === 'string' ? value.replace(CA_BASE64_PREFIX, '') : value}
</span>
)
},
style: { maxWidth: '300px' },
},
{
Expand Down
26 changes: 26 additions & 0 deletions src/components/Templates/FullPageWizard/Components.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,31 @@ export const groupHeadline = (theme: ThemeType) => css`
font-weight: 700;
line-height: 150%;
letter-spacing: -0.5px;
`

export const groupHeadlineMargin = css`
margin: 32px 0 16px 0;
`

export const flex = css`
display: flex;
align-items: center;
justify-content: space-between;
`

export const expander = (theme: ThemeType) => css`
display: flex;
align-items: center;
gap: 4px;
color: ${getTheme(theme, `FullPageWizard.expander.color`)};
cursor: pointer;
transition: color 0.3s;
&:hover {
color: ${getTheme(theme, `FullPageWizard.expander.hover.color`)};
}
`

export const expanderMargin = css`
margin-top: 20px;
`
52 changes: 50 additions & 2 deletions src/components/Templates/FullPageWizard/Components.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { FC } from 'react'
import React, { FC, useState } from 'react'
import * as styles from './Components.styles'
import ConditionalWrapper from '../../Atomic/ConditionalWrapper'
import Tooltip from '../../Atomic/Tooltip'
import IconQuestion from '../../Atomic/Icon/components/IconQuestion'
import { convertSize } from '../../Atomic/Icon'
import ShowAnimate from '../../Atomic/ShowAnimate'
import IconSettings from '../../Atomic/Icon/components/IconSettings'

export type DescriptionProps = {
children: string
Expand All @@ -18,6 +24,18 @@ export type HeadlineProps = {
export type GroupHeadlineProps = {
children: string
noBorder?: boolean
tooltipText?: string
tooltipMaxWidth?: number
}

export type ToggleConfigurationProps = {
defaultShow?: boolean
children: React.ReactNode | React.ReactNode[]
i18n: {
hide: string
show: string
}
margin?: boolean
}

export const Description: FC<DescriptionProps> = (props) => <p css={[styles.description, props.large && styles.descriptionLarge]}>{props.children}</p>
Expand All @@ -26,4 +44,34 @@ export const SubHeadline: FC<SubHeadlineProps> = (props) => <h2 css={[styles.sub

export const Headline: FC<HeadlineProps> = (props) => <h1 css={[styles.headline]}>{props.children}</h1>

export const GroupHeadline: FC<GroupHeadlineProps> = (props) => <h3 css={[styles.groupHeadline]}>{props.children}</h3>
export const GroupHeadline: FC<GroupHeadlineProps> = (props) => (
<ConditionalWrapper
condition={!!props.tooltipText}
wrapper={(children) => (
<div css={[styles.flex, styles.groupHeadlineMargin]}>
<span>{children}</span>
<Tooltip content={props.tooltipText} delay={200} maxWidth={props.tooltipMaxWidth || 300} portalTarget={document.getElementById('modal-root')!}>
<IconQuestion {...convertSize(16)} />
</Tooltip>
</div>
)}
>
<h3 css={[styles.groupHeadline, !props.tooltipText && styles.groupHeadlineMargin]}>{props.children}</h3>
</ConditionalWrapper>
)

export const ToggleConfiguration: FC<ToggleConfigurationProps> = (props) => {
const { i18n, children, margin = true } = props
const [show, setShow] = useState(false)

return (
<>
<ShowAnimate show={show}>
<>{children}</>
</ShowAnimate>
<div css={[styles.expander, margin && styles.expanderMargin]} onClick={() => setShow(!show)}>
<IconSettings /> {show ? i18n.hide : i18n.show}
</div>
</>
)
}
10 changes: 5 additions & 5 deletions src/components/Templates/FullPageWizard/FullPageWizard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import { Helmet } from 'react-helmet'
import { useTheme } from '@emotion/react'
import isFunction from 'lodash/isFunction'

Expand All @@ -11,18 +10,18 @@ import IconDone from './assets/IconDone'
import IconCloseCircle from '../../Atomic/Icon/components/IconCloseCircle'
import { convertSize } from '../../Atomic/Icon'
import { ComponentType, Props } from './FullPageWizard.types'
import { Description, SubHeadline, Headline, GroupHeadline } from './Components'
import { Description, SubHeadline, Headline, GroupHeadline, ToggleConfiguration } from './Components'
import { useDocumentTitle } from '../../../common/hooks'

const FullPageWizard: ComponentType<Props> = (props) => {
const { children, title, i18n, steps, activeStep, onStepChange, onClose, visitedStep } = props

const theme: ThemeType = useTheme()

useDocumentTitle(title)

return (
<div css={styles.wizard}>
<Helmet>
<title>{title}</title>
</Helmet>
<div css={styles.row}>
<div css={styles.leftCol}>
<div css={styles.leftInner}>
Expand Down Expand Up @@ -81,5 +80,6 @@ FullPageWizard.Description = Description
FullPageWizard.SubHeadline = SubHeadline
FullPageWizard.Headline = Headline
FullPageWizard.GroupHeadline = GroupHeadline
FullPageWizard.ToggleConfiguration = ToggleConfiguration

export default FullPageWizard
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { FC, ReactNode } from 'react'
import { DescriptionProps, HeadlineProps, SubHeadlineProps, GroupHeadlineProps } from './Components'
import { DescriptionProps, HeadlineProps, SubHeadlineProps, GroupHeadlineProps, ToggleConfigurationProps } from './Components'

export interface ComponentType<P> extends FC<P> {
Description: FC<DescriptionProps>
Headline: FC<HeadlineProps>
SubHeadline: FC<SubHeadlineProps>
GroupHeadline: FC<GroupHeadlineProps>
ToggleConfiguration: FC<ToggleConfigurationProps>
}

export type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const description = (theme: ThemeType) => css`
font-style: normal;
font-weight: 400;
line-height: 24px;
color: ${get(theme, `colorPalette.neutral900`)};
color: ${get(theme, `colorPalette.neutral500`)};
margin: 0 0 32px 0;
`

Expand Down

0 comments on commit 6f186a6

Please sign in to comment.