Skip to content

Commit

Permalink
feat: make website responsive (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
alesmit committed Feb 22, 2022
1 parent 756a965 commit cf28a16
Show file tree
Hide file tree
Showing 49 changed files with 1,253 additions and 546 deletions.
20 changes: 20 additions & 0 deletions components/Container/Container.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { render } from '@testing-library/react';

import { Container } from './Container';

describe('Container', () => {
it('should render', () => {
const { container, asFragment } = render(<Container className="pizza" />);

expect(container.children[0]).toHaveClass('container mx-auto px-4 pizza');
expect(asFragment()).toMatchSnapshot();
});

it('should render as section', () => {
const { container, asFragment } = render(<Container section />);

expect(container.children[0].tagName).toBe('SECTION');
expect(container.children[0]).toHaveClass('container mx-auto px-4');
expect(asFragment()).toMatchSnapshot();
});
});
17 changes: 17 additions & 0 deletions components/Container/Container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import clsx from 'clsx';
import React from 'react';

interface Props {
className?: string;
section?: boolean;
}

export const Container: React.FC<Props> = (props) => {
const className = clsx('container mx-auto px-4', props.className);

return props.section ? (
<section className={className}>{props.children}</section>
) : (
<div className={className}>{props.children}</div>
);
};
17 changes: 17 additions & 0 deletions components/Container/__snapshots__/Container.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Container should render 1`] = `
<DocumentFragment>
<div
class="container mx-auto px-4 pizza"
/>
</DocumentFragment>
`;

exports[`Container should render as section 1`] = `
<DocumentFragment>
<section
class="container mx-auto px-4"
/>
</DocumentFragment>
`;
1 change: 1 addition & 0 deletions components/Container/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Container } from './Container';
17 changes: 10 additions & 7 deletions components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Image from 'next/image';
import React from 'react';

import { Container } from '../Container';
import { Icon } from '../Icon';
import { FooterProject } from './Footer.blocks';

Expand All @@ -15,9 +16,9 @@ export const Footer: React.VFC = () => {

return (
<footer className="bg-secondary-800 py-10">
<div className="container mx-auto">
<div className="flex justify-between items-start">
<div>
<Container>
<div className="flex flex-col space-y-10 tablet:flex-row tablet:space-y-0 tablet:justify-between">
<div className="flex flex-col items-center text-center tablet:text-left tablet:items-start">
<div className="flex items-center mb-4">
<Icon alt="Logo" name="logo" size={32} />
<h3>Peque</h3>
Expand All @@ -29,17 +30,19 @@ export const Footer: React.VFC = () => {
{renderLink('Credits')}
</ul>
</div>
<div className="flex space-x-6">
<div className="grid grid-cols-2 laptop:grid-cols-4 gap-6 text-center tablet:text-left">
<FooterProject projectId="framework" />
<FooterProject projectId="graphql" />
<FooterProject projectId="di" />
<FooterProject projectId="smb" />
</div>
</div>
<div className="text-center mt-8">
<p>Peque packages are open source and released under the Apache 2.0 License.</p>
<p className="text-sm laptop:text-base">
Peque packages are open source and released under the Apache 2.0 License.
</p>
</div>
<div className="flex flex-col items-center mt-8 space-y-2 text-sm">
<div className="flex flex-col text-center items-center mt-8 space-y-2 text-sm">
<p className="flex items-center">
<span className="mr-1">Website hosted by</span>
<a href="https://vercel.com" target="_blank" rel="noreferrer" className="flex">
Expand All @@ -48,7 +51,7 @@ export const Footer: React.VFC = () => {
</p>
<p>Copyright © 2022 Peque. All rights reserved.</p>
</div>
</div>
</Container>
</footer>
);
};
16 changes: 10 additions & 6 deletions components/Footer/__snapshots__/Footer.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ exports[`Footer should render 1`] = `
class="bg-secondary-800 py-10"
>
<div
class="container mx-auto"
class="container mx-auto px-4"
>
<div
class="flex justify-between items-start"
class="flex flex-col space-y-10 tablet:flex-row tablet:space-y-0 tablet:justify-between"
>
<div>
<div
class="flex flex-col items-center text-center tablet:text-left tablet:items-start"
>
<div
class="flex items-center mb-4"
>
Expand Down Expand Up @@ -79,7 +81,7 @@ exports[`Footer should render 1`] = `
</ul>
</div>
<div
class="flex space-x-6"
class="grid grid-cols-2 laptop:grid-cols-4 gap-6 text-center tablet:text-left"
>
<div
class="flex flex-col"
Expand Down Expand Up @@ -234,12 +236,14 @@ exports[`Footer should render 1`] = `
<div
class="text-center mt-8"
>
<p>
<p
class="text-sm laptop:text-base"
>
Peque packages are open source and released under the Apache 2.0 License.
</p>
</div>
<div
class="flex flex-col items-center mt-8 space-y-2 text-sm"
class="flex flex-col text-center items-center mt-8 space-y-2 text-sm"
>
<p
class="flex items-center"
Expand Down
18 changes: 0 additions & 18 deletions components/Header/Header.blocks.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions components/Header/Header.helpers.ts

This file was deleted.

20 changes: 8 additions & 12 deletions components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
import clsx from 'clsx';
import React from 'react';

import { Container } from '../Container';
import { Icon } from '../Icon';
import { Nav } from './Header.blocks';
import { MainNav } from '../MainNav';

interface Props {
text?: string;
transparent?: boolean;
bgClassName?: string;
}

export const Header: React.VFC<Props> = ({ text, transparent }) => (
<header
className={clsx(
'z-10 h-16 w-full top-0 fixed',
transparent ? 'bg-secondary-900 opacity-95' : 'bg-secondary-600',
)}
>
<div className="container h-full mx-auto flex items-center justify-between">
export const Header: React.VFC<Props> = ({ text, bgClassName }) => (
<header className={clsx('z-10 h-16 w-full top-0 fixed', bgClassName)}>
<Container className="h-full flex items-center justify-between">
<div className="flex items-center">
<Icon alt="Logo" name="logo" size={40} link="/" />
<h4>{text}</h4>
</div>
<div className="flex items-center space-x-8">
<Nav />
<MainNav bgClassName={bgClassName} />
<Icon alt="Peque on GitHub" name="github" size={24} link="https://github.com/pequehq" />
</div>
</div>
</Container>
</header>
);

0 comments on commit cf28a16

Please sign in to comment.