mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
refactor: change branding delimiter to css
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
d75b8d2d3b
commit
6a772d851b
4 changed files with 35 additions and 31 deletions
|
@ -4,13 +4,11 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import { useFrontendConfig } from '../frontend-config-context/use-frontend-config'
|
import { useFrontendConfig } from '../frontend-config-context/use-frontend-config'
|
||||||
import { ShowIf } from '../show-if/show-if'
|
|
||||||
import styles from './branding.module.scss'
|
import styles from './branding.module.scss'
|
||||||
import React, { useMemo } from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export interface BrandingProps {
|
export interface BrandingProps {
|
||||||
inline?: boolean
|
inline?: boolean
|
||||||
delimiter?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,14 +18,14 @@ export interface BrandingProps {
|
||||||
* @param inline If the logo should be using the inline-size or the regular-size css class.
|
* @param inline If the logo should be using the inline-size or the regular-size css class.
|
||||||
* @param delimiter If the delimiter between the HedgeDoc logo and the branding should be shown.
|
* @param delimiter If the delimiter between the HedgeDoc logo and the branding should be shown.
|
||||||
*/
|
*/
|
||||||
export const CustomBranding: React.FC<BrandingProps> = ({ inline = false, delimiter = true }) => {
|
export const CustomBranding: React.FC<BrandingProps> = ({ inline = false }) => {
|
||||||
const branding = useFrontendConfig().branding
|
const branding = useFrontendConfig().branding
|
||||||
const showBranding = !!branding.name || !!branding.logo
|
|
||||||
|
|
||||||
const brandingDom = useMemo(() => {
|
if (!branding.name && !branding.logo) {
|
||||||
if (branding.logo) {
|
return null
|
||||||
|
} else if (branding.logo) {
|
||||||
return (
|
return (
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
/* eslint-disable-next-line @next/next/no-img-element */
|
||||||
<img
|
<img
|
||||||
src={branding.logo}
|
src={branding.logo}
|
||||||
alt={branding.name}
|
alt={branding.name}
|
||||||
|
@ -36,16 +34,6 @@ export const CustomBranding: React.FC<BrandingProps> = ({ inline = false, delimi
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return branding.name
|
return <span className={inline ? styles['inline-size'] : styles['regular-size']}>{branding.name}</span>
|
||||||
}
|
}
|
||||||
}, [branding.logo, branding.name, inline])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ShowIf condition={showBranding}>
|
|
||||||
<ShowIf condition={delimiter}>
|
|
||||||
<strong className={`mx-1 ${inline ? styles['inline-size'] : styles['regular-size']}`}>@</strong>
|
|
||||||
</ShowIf>
|
|
||||||
{brandingDom}
|
|
||||||
</ShowIf>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
/*!
|
||||||
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
.branding-separator:has(*) {
|
||||||
|
&::before {
|
||||||
|
content: '\2014';
|
||||||
|
margin-left: 0.25em;
|
||||||
|
margin-right: 0.25em;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import {
|
||||||
HedgeDocLogoType,
|
HedgeDocLogoType,
|
||||||
HedgeDocLogoWithText
|
HedgeDocLogoWithText
|
||||||
} from '../../common/hedge-doc-logo/hedge-doc-logo-with-text'
|
} from '../../common/hedge-doc-logo/hedge-doc-logo-with-text'
|
||||||
|
import styles from './branding.module.scss'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Navbar } from 'react-bootstrap'
|
import { Navbar } from 'react-bootstrap'
|
||||||
|
@ -27,7 +28,9 @@ export const NavbarBranding: React.FC = () => {
|
||||||
logoType={darkModeActivated ? HedgeDocLogoType.WB_HORIZONTAL : HedgeDocLogoType.BW_HORIZONTAL}
|
logoType={darkModeActivated ? HedgeDocLogoType.WB_HORIZONTAL : HedgeDocLogoType.BW_HORIZONTAL}
|
||||||
size={HedgeDocLogoSize.SMALL}
|
size={HedgeDocLogoSize.SMALL}
|
||||||
/>
|
/>
|
||||||
|
<span className={styles['branding-separator']}>
|
||||||
<CustomBranding inline={true} />
|
<CustomBranding inline={true} />
|
||||||
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
</Navbar.Brand>
|
</Navbar.Brand>
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,7 @@ const IntroPage: NextPage = () => {
|
||||||
<Trans i18nKey='app.slogan' />
|
<Trans i18nKey='app.slogan' />
|
||||||
</p>
|
</p>
|
||||||
<div className={'mb-5'}>
|
<div className={'mb-5'}>
|
||||||
<CustomBranding delimiter={false} />
|
<CustomBranding />
|
||||||
</div>
|
</div>
|
||||||
<CoverButtons />
|
<CoverButtons />
|
||||||
<IntroCustomContent />
|
<IntroCustomContent />
|
||||||
|
|
Loading…
Reference in a new issue