Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions entry_types/scrolled/config/locales/new/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ de:
tr: Türkisch
unknown: "(Unbekannt)"
zh: Chinesisch
navigation_skip_links:
content: Zum Inhalt
inline_editing:
cancel: Abbrechen
url_placeholder: URL eingeben oder einfügen
Expand Down
2 changes: 2 additions & 0 deletions entry_types/scrolled/config/locales/new/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ en:
tr: Turkish
unknown: "(Unknown)"
zh: Chinese
navigation_skip_links:
content: To the content
inline_editing:
cancel: Cancel
url_placeholder: Type or paste URL
Expand Down
23 changes: 23 additions & 0 deletions entry_types/scrolled/package/spec/frontend/SkipLinks-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';

import {SkipLinks} from 'frontend/navigation/SkipLinks';
import styles from 'frontend/navigation/SkipLinks.module.css';

import {render} from '@testing-library/react';

describe('SkipLinks', () => {
it('renders skip links', async () => {
const {getByText} = render(<SkipLinks />);

expect(getByText(/content/).classList.contains(styles.link)).toBe(true);
});

it('focus the button', async () => {
const {container} = render(<SkipLinks />);

const elem = document.getElementsByClassName(styles.link)[0];
elem.focus();

expect(document.activeElement).toBe(elem);
});
});
2 changes: 1 addition & 1 deletion entry_types/scrolled/package/src/frontend/Entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default withInlineEditingDecorator('EntryDecorator', function Entry(props
}

return (
<div className={styles.Entry}>
<div className={styles.Entry} id='goToContent'>
<AtmoProvider>
<ScrollToSectionContext.Provider value={scrollToSection}>
{renderChapters(entryStructure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {LegalInfoMenu} from "./LegalInfoMenu";
import {SharingMenu} from "./SharingMenu";
import {ToggleMuteButton} from './ToggleMuteButton';
import {Logo} from './Logo';
import {SkipLinks} from './SkipLinks';

import styles from './AppHeader.module.css';

Expand Down Expand Up @@ -90,6 +91,7 @@ export function AppHeader(props) {
<HamburgerIcon onClick={handleBurgerMenuClick}
mobileNavHidden={mobileNavHidden}/>

<SkipLinks />
<Logo />

<nav className={classNames(styles.navigationChapters, {[styles.navigationChaptersHidden]: mobileNavHidden})}
Expand Down
22 changes: 22 additions & 0 deletions entry_types/scrolled/package/src/frontend/navigation/SkipLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';

import I18n from 'i18n-js';

import styles from './SkipLinks.module.css';

export function SkipLinks() {

function scrollDown() {
setTimeout(() => {
window.scrollTo(0, 50);
}, 50);
}

return (
<div id='skipLinks'>
<a href='#goToContent' className={styles.link} onClick={scrollDown}>
{I18n.t('pageflow_scrolled.public.navigation_skip_links.content')}
</a>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.link {
position: absolute;
z-index: 10000;
top: -1000em;
left: -1000em;

display: block;
border: 1px solid #eeeeee;
border-radius: 5px;
padding: 5px 5px;
background: #00375a;
text-align: center;
line-height: 25px;
color: #ffffff;
}

.link:focus {
left: 13.8%;
top: 13%;
}