-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add responsive styles to registration page (#5044)
The responsive style of the login and registration page has been adjusted, with special treatment given to the input. work for #4843
- Loading branch information
Showing
18 changed files
with
338 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/frontend/component/src/components/affine-other-page-layout/desktop-navbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as styles from './index.css'; | ||
import { useNavConfig } from './use-nav-config'; | ||
|
||
export const DesktopNavbar = () => { | ||
const config = useNavConfig(); | ||
|
||
return ( | ||
<div className={styles.topNavLinks}> | ||
{config.map(item => { | ||
return ( | ||
<a | ||
key={item.title} | ||
href={item.path} | ||
target="_blank" | ||
rel="noreferrer" | ||
className={styles.topNavLink} | ||
> | ||
{item.title} | ||
</a> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; |
89 changes: 89 additions & 0 deletions
89
packages/frontend/component/src/components/affine-other-page-layout/index.css.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const root = style({ | ||
height: '100vh', | ||
width: '100vw', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
fontSize: 'var(--affine-font-base)', | ||
position: 'relative', | ||
background: 'var(--affine-background-primary-color)', | ||
}); | ||
|
||
export const affineLogo = style({ | ||
color: 'inherit', | ||
}); | ||
|
||
export const topNav = style({ | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
padding: '16px 120px', | ||
selectors: { | ||
'&.mobile': { | ||
padding: '16px 20px', | ||
}, | ||
}, | ||
}); | ||
|
||
export const topNavLinks = style({ | ||
display: 'flex', | ||
columnGap: 4, | ||
}); | ||
|
||
export const topNavLink = style({ | ||
color: 'var(--affine-text-primary-color)', | ||
fontSize: 'var(--affine-font-sm)', | ||
fontWeight: 500, | ||
textDecoration: 'none', | ||
padding: '4px 18px', | ||
}); | ||
|
||
export const iconButton = style({ | ||
fontSize: '24px', | ||
pointerEvents: 'auto', | ||
selectors: { | ||
'&.plain': { | ||
color: 'var(--affine-text-primary-color)', | ||
}, | ||
}, | ||
}); | ||
|
||
export const menu = style({ | ||
width: '100vw', | ||
height: '100vh', | ||
padding: '0', | ||
background: 'var(--affine-background-primary-color)', | ||
borderRadius: '0', | ||
border: 'none', | ||
boxShadow: 'none', | ||
}); | ||
|
||
export const menuItem = style({ | ||
color: 'var(--affine-text-primary-color)', | ||
fontSize: 'var(--affine-font-sm)', | ||
fontWeight: 500, | ||
textDecoration: 'none', | ||
padding: '12px 20px', | ||
maxWidth: '100%', | ||
position: 'relative', | ||
borderRadius: '0', | ||
transition: 'background 0.3s ease', | ||
selectors: { | ||
'&:after': { | ||
position: 'absolute', | ||
content: '""', | ||
bottom: 0, | ||
display: 'block', | ||
width: 'calc(100% - 40px)', | ||
height: '0.5px', | ||
background: 'var(--affine-black-10)', | ||
}, | ||
'&:not(:last-of-type)': { | ||
marginBottom: '0', | ||
}, | ||
}, | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/frontend/component/src/components/affine-other-page-layout/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './layout'; |
49 changes: 49 additions & 0 deletions
49
packages/frontend/component/src/components/affine-other-page-layout/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Button } from '@affine/component/ui/button'; | ||
import { useAFFiNEI18N } from '@affine/i18n/hooks'; | ||
import { Logo1Icon } from '@blocksuite/icons'; | ||
import clsx from 'clsx'; | ||
import { useCallback } from 'react'; | ||
|
||
import { DesktopNavbar } from './desktop-navbar'; | ||
import * as styles from './index.css'; | ||
import { MobileNavbar } from './mobile-navbar'; | ||
|
||
export const AffineOtherPageLayout = ({ | ||
isSmallScreen, | ||
children, | ||
}: { | ||
isSmallScreen: boolean; | ||
children: React.ReactNode; | ||
}) => { | ||
const t = useAFFiNEI18N(); | ||
|
||
const openDownloadLink = useCallback(() => { | ||
open(runtimeConfig.downloadUrl, '_blank'); | ||
}, []); | ||
|
||
return ( | ||
<div className={styles.root}> | ||
<div | ||
className={clsx(styles.topNav, { | ||
mobile: isSmallScreen, | ||
})} | ||
> | ||
<a href="/" rel="noreferrer" className={styles.affineLogo}> | ||
<Logo1Icon width={24} height={24} /> | ||
</a> | ||
{isSmallScreen ? ( | ||
<MobileNavbar /> | ||
) : ( | ||
<> | ||
<DesktopNavbar /> | ||
<Button onClick={openDownloadLink}> | ||
{t['com.affine.auth.open.affine.download-app']()} | ||
</Button> | ||
</> | ||
)} | ||
</div> | ||
|
||
{children} | ||
</div> | ||
); | ||
}; |
50 changes: 50 additions & 0 deletions
50
packages/frontend/component/src/components/affine-other-page-layout/mobile-navbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { IconButton } from '@affine/component/ui/button'; | ||
import { Menu, MenuItem } from '@affine/component/ui/menu'; | ||
import { CloseIcon, PropertyIcon } from '@blocksuite/icons'; | ||
import { useState } from 'react'; | ||
|
||
import * as styles from './index.css'; | ||
import { useNavConfig } from './use-nav-config'; | ||
|
||
export const MobileNavbar = () => { | ||
const [openMenu, setOpenMenu] = useState(false); | ||
const navConfig = useNavConfig(); | ||
|
||
const menuItems = ( | ||
<> | ||
{navConfig.map(item => { | ||
return ( | ||
<MenuItem | ||
key={item.title} | ||
onClick={() => { | ||
open(item.path, '_blank'); | ||
}} | ||
className={styles.menuItem} | ||
> | ||
{item.title} | ||
</MenuItem> | ||
); | ||
})} | ||
</> | ||
); | ||
|
||
return ( | ||
<div> | ||
<Menu | ||
items={menuItems} | ||
contentOptions={{ | ||
className: styles.menu, | ||
sideOffset: 20, | ||
}} | ||
rootOptions={{ | ||
open: openMenu, | ||
onOpenChange: setOpenMenu, | ||
}} | ||
> | ||
<IconButton type="plain" className={styles.iconButton}> | ||
{openMenu ? <CloseIcon /> : <PropertyIcon />} | ||
</IconButton> | ||
</Menu> | ||
</div> | ||
); | ||
}; |
27 changes: 27 additions & 0 deletions
27
packages/frontend/component/src/components/affine-other-page-layout/use-nav-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useAFFiNEI18N } from '@affine/i18n/hooks'; | ||
import { useMemo } from 'react'; | ||
|
||
export const useNavConfig = () => { | ||
const t = useAFFiNEI18N(); | ||
return useMemo( | ||
() => [ | ||
{ | ||
title: t['com.affine.other-page.nav.official-website'](), | ||
path: 'https://affine.pro', | ||
}, | ||
{ | ||
title: t['com.affine.other-page.nav.affine-community'](), | ||
path: 'https://community.affine.pro/home', | ||
}, | ||
{ | ||
title: t['com.affine.other-page.nav.blog'](), | ||
path: 'https://affine.pro/blog', | ||
}, | ||
{ | ||
title: t['com.affine.other-page.nav.contact-us'](), | ||
path: 'https://affine.pro/about-us', | ||
}, | ||
], | ||
[t] | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 29 additions & 20 deletions
49
packages/frontend/component/src/components/auth-components/auth-page-container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
import type { FC, PropsWithChildren, ReactNode } from 'react'; | ||
import { | ||
type FC, | ||
type PropsWithChildren, | ||
type ReactNode, | ||
useEffect, | ||
useState, | ||
} from 'react'; | ||
|
||
import { Empty } from '../../ui/empty'; | ||
import { Wrapper } from '../../ui/layout'; | ||
import { Logo } from './logo'; | ||
import { AffineOtherPageLayout } from '../affine-other-page-layout'; | ||
import { authPageContainer } from './share.css'; | ||
|
||
export const AuthPageContainer: FC< | ||
PropsWithChildren<{ title?: ReactNode; subtitle?: ReactNode }> | ||
> = ({ children, title, subtitle }) => { | ||
const [isSmallScreen, setIsSmallScreen] = useState(false); | ||
|
||
useEffect(() => { | ||
const checkScreenSize = () => { | ||
setIsSmallScreen(window.innerWidth <= 1024); | ||
}; | ||
checkScreenSize(); | ||
window.addEventListener('resize', checkScreenSize); | ||
return () => window.removeEventListener('resize', checkScreenSize); | ||
}, []); | ||
|
||
return ( | ||
<div className={authPageContainer}> | ||
<Wrapper | ||
style={{ | ||
position: 'absolute', | ||
top: 25, | ||
left: 20, | ||
}} | ||
> | ||
<Logo /> | ||
</Wrapper> | ||
<div className="wrapper"> | ||
<div className="content"> | ||
<p className="title">{title}</p> | ||
<p className="subtitle">{subtitle}</p> | ||
{children} | ||
<AffineOtherPageLayout isSmallScreen={isSmallScreen}> | ||
<div className={authPageContainer}> | ||
<div className="wrapper"> | ||
<div className="content"> | ||
<p className="title">{title}</p> | ||
<p className="subtitle">{subtitle}</p> | ||
{children} | ||
</div> | ||
{isSmallScreen ? null : <Empty />} | ||
</div> | ||
<Empty /> | ||
</div> | ||
</div> | ||
</AffineOtherPageLayout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.