Skip to content

Commit

Permalink
feat(skip-link): 본문 바로가기 링크 추가 (#2)
Browse files Browse the repository at this point in the history
본문 바로가기 링크를 추가하여 키보드 접근성을 높임

Resolved #2

Signed-off-by: chayeoi <chayeoikeem@gmail.com>
  • Loading branch information
chayeoi committed Feb 23, 2020
1 parent 74c7ee6 commit 0b9aaae
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { css } from '@emotion/core'
import { graphql, useStaticQuery } from 'gatsby'
import React from 'react'

import { HEADER_MIN_HEIGHT } from '../constants'
import { CONTENT_LINK, HEADER_MIN_HEIGHT } from '../constants'
import Footer from './footer'
import Header from './header'
import SkipLink from './skip-link'

interface Props {
children: React.ReactNode;
Expand All @@ -23,9 +24,10 @@ const Layout: React.FC<Props> = ({ children }) => {

return (
<div css={s.root}>
<SkipLink />
<Header siteTitle={data.site.siteMetadata.title} />
<div css={s.wrapper}>
<main css={s.main}>{children}</main>
<main id={CONTENT_LINK} css={s.main}>{children}</main>
<Footer />
</div>
</div>
Expand Down
37 changes: 37 additions & 0 deletions src/components/skip-link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/** @jsx jsx */
import { css, jsx, SerializedStyles } from '@emotion/core'

import { CONTENT_LINK } from '../constants'
import { Theme } from '../models/Theme'

/**
* @
*/
const SkipLink: React.FC = props => (
<a css={s.root} href={`#${CONTENT_LINK}`} {...props}>
본문 바로가기
</a>
)

const s = {
root: (theme: Theme): SerializedStyles => css`
position: fixed;
z-index: 1000;
top: 24px;
left: 16px;
padding: 12px 16px;
border-radius: 2px;
font-size: 14px;
color: ${theme.palette.primary.contrastText};
background-color: ${theme.palette.primary.main};
transform-style: preserve-3d;
transform: perspective(800px) translateY(-100px) rotateX(-1turn);
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
:focus {
color: ${theme.palette.primary.contrastText};
transform: none;
}
`,
}

export default SkipLink
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { default as ColorMode } from './color-mode'
export { default as UtterancesTheme } from './utterances-theme'
export * from './icons'
export * from './link'
export * from './media-types'
export * from './palette'
export * from './size'
Expand Down
1 change: 1 addition & 0 deletions src/constants/link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const CONTENT_LINK = 'content'

0 comments on commit 0b9aaae

Please sign in to comment.