Skip to content

Commit

Permalink
Merge pull request #5 from luck-js/develop
Browse files Browse the repository at this point in the history
v1.2.0-alpha
  • Loading branch information
dkarski authored Oct 27, 2019
2 parents 5576093 + f7d4a7e commit 32270ce
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 76 deletions.
2 changes: 1 addition & 1 deletion components/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
display,
} from 'styled-system';

export const Box = styled('div')(
export const Box = styled('div')<any>(
space,
color,
width,
Expand Down
8 changes: 4 additions & 4 deletions components/Button/NavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import styled from 'styled-components';
import { BaseButton } from './BaseButton';
import * as React from 'react';

const NavLink = ({ modifiers, ...props }: { modifiers?: string[]; href: string }) => {
const NavLink = ({ modifiers, href, ariaLabel, ...props }: { modifiers?: string[]; href: string, ariaLabel: string }) => {
return (
<NavLink.Container>
<Link {...props}>
<NavLink.Button as={'a'} modifiers={modifiers}>
<NavLink.Container {...props}>
<Link href={href}>
<NavLink.Button href={href} ariaLabel={ariaLabel} as={'a'} modifiers={modifiers}>
Blog
</NavLink.Button>
</Link>
Expand Down
6 changes: 3 additions & 3 deletions components/Card/CardDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ const CardDesktop: React.FunctionComponent<CardDesktopProps> = ({
<Fragment>
{cover && (
<Container {...props}>
<Link href={`/blog/${slug}`}>
<Box>
<Link href={`/blog/${slug}`}>
<Box as="a" href={`/blog/${slug}`} aria-label={`przejdź do ${title}`}>
<ImageContainer ratio="69%">
<p>{cover.url}</p>
<Image src={cover.url} alt="" />
Expand All @@ -81,7 +81,7 @@ const CardDesktop: React.FunctionComponent<CardDesktopProps> = ({
<span key={`CardDesktop-${name}-${index}`}>#{name}</span>
))}
</Hashtags>
<Trafalgar tag="h3" pt={['xsmall', 'xsmall', 'xsmall', 'xsmall']}>
<Trafalgar tag="h2" pt={['xsmall', 'xsmall', 'xsmall', 'xsmall']}>
{title}
</Trafalgar>
</ContentContainer>
Expand Down
4 changes: 2 additions & 2 deletions components/Card/CardMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ const CardMobile: React.FunctionComponent<CardMobileProps> = ({
<Container {...props}>
<InnerContainer>
<Link href={`/blog/${slug}`}>
<Box>
<Box as="a" href={`/blog/${slug}`} aria-label={`przejdź do ${title}`}>
<ImageContainer ratio="69%">
<p>{cover.url}</p>
<Image src={cover.url} alt="" />
</ImageContainer>
<ContentContainer>
<Trafalgar tag="h3">{title}</Trafalgar>
<Trafalgar tag="h2">{title}</Trafalgar>
</ContentContainer>
</Box>
</Link>
Expand Down
5 changes: 5 additions & 0 deletions components/GlobalStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const GlobalStyle = createGlobalStyle`
color: ${Theme.colors.main};
font-family: ${Theme.fontFamilies.body} ;
}
a {
color: inherit;
text-decoration: none;
}
`;

export default GlobalStyle;
4 changes: 1 addition & 3 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useEffect } from 'react';
import Fonts from '../utils/fonts';

type LayoutProps = {
title?: string;
backgroundColor: string;
};
const Container = styled(Box)`
Expand All @@ -19,7 +18,7 @@ const InnerContainer = styled('div')<{ isFontLoaded: boolean }>`
transition: 0.5s;
`;

const Layout: React.FunctionComponent<LayoutProps> = ({ children, title, ...props }) => {
const Layout: React.FunctionComponent<LayoutProps> = ({ children, ...props }) => {
const [isFontLoaded, setIsFontLoaded] = useState(false);
useEffect(() => {
let isSubscribed = true
Expand All @@ -30,7 +29,6 @@ const Layout: React.FunctionComponent<LayoutProps> = ({ children, title, ...prop
return (
<Container {...props}>
<Head>
<title>{title}</title>
<meta charSet="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
Expand Down
19 changes: 15 additions & 4 deletions components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,20 @@ const NavigationContainer = styled(Flex)`
`}
`;

const NavigationLogo = styled('img')`
const NavigationLogoContainer = styled(Box)`
height: 100%;
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
transition: transform 0.5s;
&:hover {
transform: translateX(-50%) scale(1.11);
}
`

const NavigationLogo = styled('img')`
height: 100%;
cursor: pointer;
`;
Expand All @@ -65,12 +74,14 @@ export const Navigation: React.FunctionComponent<NavigationProps> = ({
<NavigationHorizontalPadding>
<NavigationContainer>
{shouldDisplayLogo && (
<Link href={`/`} >
<NavigationLogo src="/static/logo-luck.png" />
<Link href="/" >
<NavigationLogoContainer as="a" href="/" aria-label={`przejdź do strony głownej`}>
<NavigationLogo src="/static/logo-luck.png" alt="Logo Luck" />
</NavigationLogoContainer>
</Link>
)}

<NavLink href="/blog" modifiers={navLinkModifiers} />
<NavLink href="/blog" ariaLabel="przejdź do blog postow" modifiers={navLinkModifiers} />
</NavigationContainer>
</NavigationHorizontalPadding>
);
Expand Down
23 changes: 23 additions & 0 deletions next-seo.config.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const title = 'Luck - Organizacja Mikołajek nie była nigdy tak łatwa!';
export const description =
'Poznaj Aplikcaje Luck, która ułatwi Ci z organizowanie mikołajek. Świetnie się na da na mikołajki klasowe, jak i zarówno te organizowane w domu rodzinnym';

export default {
title,
description,
openGraph: {
title,
description,
url: 'https://luck.org.pl',
locale: 'pl_PL',
images: [
{
url: 'https://luck.org.pl/static/logo-luck.png',
width: 488,
height: 488,
alt: 'Luck Logo',
},
],
site_name: 'Aplikacja Luck',
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"next": "^9.0.5",
"next-apollo": "^3.1.4",
"next-ga": "^2.3.4",
"next-seo": "^2.2.1",
"nodemon": "^1.19.2",
"react": "^16.9.0",
"react-apollo": "^3.1.0",
Expand Down
4 changes: 4 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import App, { Container } from 'next/app';
import Router from "next/router";
import { DefaultSeo } from 'next-seo';
import { ThemeProvider } from 'styled-components';
import GlobalStyle from '../components/GlobalStyle';
import {Theme} from "../utils"
import SEO from '../next-seo.config';

// @ts-ignore
import withGA from "next-ga";

Expand All @@ -15,6 +18,7 @@ class MyApp extends App<{analytics: any}> {
<ThemeProvider theme={Theme}>
<>
<GlobalStyle />
<DefaultSeo {...SEO} />
<Component {...pageProps} analytics={analytics} />
</>
</ThemeProvider>
Expand Down
1 change: 1 addition & 0 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MyDocument extends Document {
<Html lang="en-US">
<Head>
<meta charSet="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<body>
Expand Down
1 change: 0 additions & 1 deletion pages/blog/BlogLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Layout from '../../components/Layout';
import { Navigation } from '../../components';

type LayoutProps = {
title?: string;
backgroundColor: string;
};

Expand Down
73 changes: 49 additions & 24 deletions pages/blog/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React, { Fragment } from 'react';
import React from 'react';
import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';
import styled from 'styled-components';
import { NextSeo } from 'next-seo/lib';
import RatioContainer from '../../components/RatioContainer';
import {MediumText, Canon, Flex, TinySecond} from '../../components';
import { MediumText, Canon, Flex, TinySecond } from '../../components';
import BlogLayout from './BlogLayout';
import { mapToPost } from './index';
import { withApollo, getProcessor, Theme, Post, QueryPostsArgs, Hashtag } from '../../utils';
import media from '../../utils/media';

const ContentImage = styled("img")`
const ContentImage = styled('img').attrs({alt: ""})`
width: 100%;
padding: ${Theme.space.small}px 0;
Expand All @@ -26,11 +27,11 @@ const ContentImage = styled("img")`
${media.greaterThan('desktop')`
padding: ${Theme.space.xregular}px 0;
`}
`
`;

const components = {
"p": MediumText,
"img": ContentImage
p: MediumText,
img: ContentImage,
};

const processor = getProcessor(components);
Expand Down Expand Up @@ -84,39 +85,63 @@ const HashtagsText = styled(TinySecond)`

const PostContent: React.FunctionComponent<Post> = ({
title,
description,
content,
createdAt,
updatedAt,
cover,
hashtags = [],
...props
}) => (
<Fragment>
<>
{cover && (
<Container {...props}>
<ImageContainer ratio={["62.5%","34%"]}>
<Image src={cover.url} alt="" />
</ImageContainer>
<ContentContainer>
<Canon pb={['small', 'small', 'regular', 'regular']}>{title}</Canon>
{processor.processSync(content).contents}
<HashtagsText pt={['small', 'small', 'regular', 'regular']}>
{(hashtags as Hashtag[]).map(({ name }, index) => (
<span key={`PostContent-${name}-${index}`}>#{name}</span>
))}
</HashtagsText>
</ContentContainer>
</Container>
<>
<NextSeo
title={`Luck - ${title}`}
description={description}
openGraph={{
title,
description,
url: window.location.href,
images: [{ url: cover.url }],
article: {
publishedTime: createdAt,
modifiedTime: updatedAt,
// authors: [authors],
// section: category.name,
tags: (hashtags as Hashtag[]).map(({ name }) => name),
},
}}
/>
<Container {...props}>
<ImageContainer ratio={['62.5%', '34%']}>
<Image src={cover.url} alt="" />
</ImageContainer>
<ContentContainer>
<Canon pb={['small', 'small', 'regular', 'regular']}>{title}</Canon>
{processor.processSync(content).contents}
<HashtagsText pt={['small', 'small', 'regular', 'regular']}>
{(hashtags as Hashtag[]).map(({ name }, index) => (
<span key={`PostContent-${name}-${index}`}>#{name}</span>
))}
</HashtagsText>
</ContentContainer>
</Container>
</>
)}
</Fragment>
</>
);

export const POST_QUERY = gql`
query getPosts($where: JSON) {
posts(where: $where) {
title
content
description
content
slug
isDraft
createdAt
updatedAt
cover {
url
}
Expand All @@ -141,7 +166,7 @@ const Index: StatelessPage = ({ slug, cmsUrl }) => {
if (loading) return <div>Loading</div>;

return (
<BlogLayout title="Blog | Luck" backgroundColor={Theme.colors.main}>
<BlogLayout backgroundColor={Theme.colors.main}>
{data && data.posts[0] && <PostContent {...mapToPost(data.posts[0], cmsUrl)} />}
</BlogLayout>
);
Expand Down
Loading

0 comments on commit 32270ce

Please sign in to comment.