-
-
Notifications
You must be signed in to change notification settings - Fork 871
Header slots #7550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arybakov05
wants to merge
26
commits into
seven
Choose a base branch
from
6673-seven-header-slots
base: seven
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Header slots #7550
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cc0eab9
fix authentication
arybakov05 b6e7e18
restructured header tools slots
arybakov05 e161a9a
added HeaderTools sub-slots
arybakov05 56be089
Merge branch 'seven' into 6673-seven-header-slots
arybakov05 0fa2701
Merge branch 'seven' into 6673-seven-header-slots
avoinea 51e1d42
added missing news
arybakov05 17d2fe3
Merge remote-tracking branch 'origin/6673-seven-header-slots' into 66…
arybakov05 450f4a7
Merge branch 'seven' into 6673-seven-header-slots
arybakov05 20d42b1
Merge branch 'seven' into 6673-seven-header-slots
arybakov05 eebdf1b
merge seven into 6673-seven-header-slots
arybakov05 7802977
added missing news
arybakov05 52e0c1f
Merge branch 'seven' into 6673-seven-header-slots
arybakov05 987c129
clean up after merge conflicts, replace search svg with icon
arybakov05 31eaa9d
fix prettier
arybakov05 44f8b98
use user from context instead of token
arybakov05 3f1c00b
Merge branch 'seven' into 6673-seven-header-slots
arybakov05 f4f55bf
remove unnecessary `flattenToAppURL` call
arybakov05 2481490
use native form behavior for search widget
arybakov05 882e040
rename slots
arybakov05 78d467c
Merge branch 'seven' into 6673-seven-header-slots
arybakov05 8b114f9
Merge seven into 66673-seven-header-slots
arybakov05 c265832
move styles from header.css to the correct modules
arybakov05 2c5cafb
remove space from language switcher slot name
arybakov05 7263e85
Merge branch 'refs/heads/seven' into 6673-seven-header-slots
arybakov05 5b9ab13
rename siteActions locale to actions, update pnpm-lock file
arybakov05 e45f43a
Merge branch 'seven' into 6673-seven-header-slots
arybakov05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| Include `isAuthenticated` boolean in root loader data. @arybakov05 |
This file contains hidden or 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 hidden or 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,32 @@ | ||
| { | ||
| "layout": { | ||
| "slots": { | ||
| "tools": { | ||
| "languageSwitcher": { | ||
| "switchTo": "Zu {{ lang }} wechseln" | ||
| }, | ||
| "siteActions": { | ||
| "logout": "Abmelden" | ||
| }, | ||
| "anonymousTools": { | ||
| "login": "Anmelden", | ||
| "register": "Registrieren" | ||
| }, | ||
| "searchwidget": { | ||
| "searchSite": "Seite durchsuchen" | ||
| } | ||
| } | ||
| }, | ||
| "contenttypes": { | ||
| "common": { | ||
| "size": "Größe:" | ||
| }, | ||
| "image": { | ||
| "download": "Klicke, um das Bild in voller Größe herunterzuladen" | ||
| }, | ||
| "file": { | ||
| "download": "Datei herunterladen" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| Added search widget and header sub-slots. @arybakov05 |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -26,12 +26,7 @@ const Header = (props: HeaderProps) => { | |
| <SlotRenderer name="navigation" content={content} location={location} /> | ||
| <div className={clsx(styles['header-tools'], 'header-tools')}> | ||
| <SlotRenderer | ||
| name="headertools" | ||
| content={content} | ||
| location={location} | ||
| /> | ||
| <SlotRenderer | ||
| name="language-switcher" | ||
| name="headerTools" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok on doing this, and move it inside the tools. |
||
| content={content} | ||
| location={location} | ||
| /> | ||
|
|
||
This file contains hidden or 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,12 @@ | ||
| import { Link } from '@plone/components'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| const Actions = () => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <Link href="/logout">{t('layout.slots.tools.siteActions.logout')}</Link> | ||
| ); | ||
| }; | ||
|
|
||
| export default Actions; |
This file contains hidden or 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,29 @@ | ||
| import clsx from 'clsx'; | ||
| import type { SlotComponentProps } from '../SlotRenderer'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { Link } from '@plone/components'; | ||
| import config from '@plone/registry'; | ||
| import styles from './Tools.module.css'; | ||
|
|
||
| const AnonymousTools = (props: SlotComponentProps) => { | ||
| const { content } = props; | ||
| const { t } = useTranslation(); | ||
|
|
||
| const returnUrl = content['@id']; | ||
| const hasReturnUrl = returnUrl !== '' && returnUrl !== '/'; | ||
|
|
||
| return ( | ||
| <div className={clsx(styles['anonymoustools'], 'anonymoustools')}> | ||
| <Link href={`/login${hasReturnUrl ? `?return_url=${returnUrl}` : ''}`}> | ||
| {t('layout.slots.tools.anonymousTools.login')} | ||
| </Link> | ||
| {config.settings.showSelfRegistration && ( | ||
| <Link href="/register"> | ||
| {t('layout.slots.tools.anonymousTools.register')} | ||
| </Link> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default AnonymousTools; |
This file contains hidden or 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,36 @@ | ||
| import SlotRenderer, { type SlotComponentProps } from '../SlotRenderer'; | ||
| import { useRouteLoaderData } from 'react-router'; | ||
| import type { RootLoader } from 'seven/app/root'; | ||
|
|
||
| const HeaderTools = (props: SlotComponentProps) => { | ||
| const rootData = useRouteLoaderData<RootLoader>('root'); | ||
|
|
||
| if (!rootData) { | ||
| return null; | ||
| } | ||
|
|
||
| const { isAuthenticated } = rootData; | ||
| const { content, location } = props; | ||
|
|
||
| return ( | ||
| <> | ||
| {isAuthenticated ? ( | ||
| <SlotRenderer name="actions" content={content} location={location} /> | ||
| ) : ( | ||
| <SlotRenderer | ||
| name="anonymousTools" | ||
| content={content} | ||
| location={location} | ||
| /> | ||
| )} | ||
| <SlotRenderer | ||
| name="languageSwitcher" | ||
| content={content} | ||
| location={location} | ||
| /> | ||
| <SlotRenderer name="searchWidget" content={content} location={location} /> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default HeaderTools; |
This file contains hidden or 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,39 @@ | ||
| import { Form, Input, Label, TextField } from 'react-aria-components'; | ||
| import type { SlotComponentProps } from '../SlotRenderer'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { Button } from '@plone/components'; | ||
| import Search from '@plone/components/icons/search.svg?react'; | ||
| import styles from './Tools.module.css'; | ||
| import clsx from 'clsx'; | ||
|
|
||
| const SearchWidget = (props: SlotComponentProps) => { | ||
| const { location } = props; | ||
|
|
||
| const { t } = useTranslation(); | ||
| const pathname = location.pathname; | ||
| const hasPath = pathname?.length > 0 && pathname !== '/'; | ||
|
|
||
| return ( | ||
| <Form | ||
| className={clsx(styles['searchwidget'], 'searchwidget')} | ||
| action="/search" | ||
| method="get" | ||
| > | ||
|
pnicolli marked this conversation as resolved.
|
||
| <TextField name="search" type="text"> | ||
| <Label className="sr-only"> | ||
| {t('layout.slots.tools.searchWidget.searchSite')} | ||
| </Label> | ||
| <Input | ||
| name="SearchableText" | ||
| placeholder={t('layout.slots.tools.searchWidget.searchSite')} | ||
| /> | ||
| {hasPath && <input type="hidden" name="path" value={pathname} />} | ||
| </TextField> | ||
| <Button type="submit"> | ||
| <Search /> | ||
| </Button> | ||
| </Form> | ||
| ); | ||
| }; | ||
|
|
||
| export default SearchWidget; | ||
This file contains hidden or 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,53 @@ | ||
| @layer custom { | ||
| .anonymoustools { | ||
| display: flex; | ||
| flex-direction: row; | ||
| align-items: center; | ||
| gap: 1rem; | ||
| } | ||
|
|
||
| .searchwidget { | ||
| display: flex; | ||
| flex-direction: row-reverse; | ||
| border: 2px solid transparent; | ||
| border-radius: 8px; | ||
| gap: 2px; | ||
|
|
||
| &:focus-within, | ||
| &:hover { | ||
| border: 2px solid var(--border); | ||
| } | ||
|
|
||
| input { | ||
| max-width: 200px; | ||
| height: 100%; | ||
| padding: 2px 8px; | ||
| border-radius: 0 8px 8px 0; | ||
| border-left: 2px solid transparent; | ||
|
|
||
| &:focus-visible { | ||
| outline: 2px solid var(--quanta-cobalt); | ||
| } | ||
| } | ||
|
|
||
| button { | ||
| box-sizing: content-box; | ||
| padding: 8px; | ||
| border-radius: 8px 0 0 8px; | ||
| background-color: transparent; | ||
|
|
||
| &:hover { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| &:focus { | ||
| outline: 2px solid var(--quanta-cobalt); | ||
| outline-offset: 0; | ||
| } | ||
|
|
||
| svg { | ||
| opacity: 0.7; | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.