Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Remove SC and refactor the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri Yakovlev committed May 16, 2020
1 parent 76b91f3 commit cdb86cf
Show file tree
Hide file tree
Showing 55 changed files with 4,573 additions and 4,890 deletions.
12 changes: 1 addition & 11 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
{
"presets": ["next/babel"],
"plugins": [
["styled-components", { "ssr": true }],
"inline-react-svg",
[
"import",
{
"libraryName": "antd",
"style": "css"
}
]
]
"plugins": ["inline-react-svg"]
}
6 changes: 0 additions & 6 deletions .nowignore

This file was deleted.

5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ notifications:
on_failure: always

stages:
- test
- name: update-algolia
if: (NOT type IN (pull_request)) AND (branch = master)

jobs:
include:
- stage: test
script:
- yarn test-ci

- stage: update-algolia
script: yarn update-speakers
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Yuri Yakovlev
Copyright (c) 2020 Yuri Yakovlev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 13 additions & 0 deletions apiHooks/useAlgolia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import useSWR from 'swr';

import fetch from '../libs/fetch';

const useAlgolia = (phrase: string, initialData: any = {}) => {
return useSWR(
`/api/getSpeakers${phrase ? `?phrase=${phrase}` : ''}`,
fetch,
initialData,
);
};

export default useAlgolia;
9 changes: 9 additions & 0 deletions apiHooks/useTwitter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import useSWR from 'swr';

import fetch from '../libs/fetch';

const useTwitterImage = (username: string) => {
return useSWR(`/api/twitter?username=${username}`, fetch);
};

export default useTwitterImage;
55 changes: 26 additions & 29 deletions components/RefinementList.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
import { Checkbox } from 'antd';
import { connectRefinementList } from 'react-instantsearch-dom';
import styled from 'styled-components';

const Wrapper = styled.div`
display: grid;
grid-gap: 20px;
grid-template-columns: repeat(2, 1fr);
padding: 20px 0 40px;
// const Wrapper = styled.div`
// display: grid;
// grid-gap: 20px;
// grid-template-columns: repeat(2, 1fr);
// padding: 20px 0 40px;

@media (min-width: 768px) {
grid-template-columns: repeat(3, 1fr);
}
// @media (min-width: 768px) {
// grid-template-columns: repeat(3, 1fr);
// }

@media (min-width: 1440px) {
grid-template-columns: repeat(6, 1fr);
}
// @media (min-width: 1440px) {
// grid-template-columns: repeat(6, 1fr);
// }
// `;

.ant-checkbox-wrapper + .ant-checkbox-wrapper {
margin: 0;
}
`;

const RefinementList = connectRefinementList(({ items, refine }) => {
return (
<Wrapper>
{items.map(item => (
<Checkbox
const RefinementList = connectRefinementList(({ items, refine }) => (
<div>
{items.map((item) => (
<>
<input
type="checkbox"
onChange={() => refine(item.value)}
checked={item.isRefined}
key={item.label.toLowerCase()}
>
/>

<label>
{item.label} ({item.count})
</Checkbox>
))}
</Wrapper>
);
});
</label>
</>
))}
</div>
));

export default RefinementList;
9 changes: 1 addition & 8 deletions components/SearchBox.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Input } from 'antd';
import debounce from 'lodash.debounce';
import { useState } from 'react';
import { connectSearchBox } from 'react-instantsearch-dom';
import styled from 'styled-components';

const StyledInput = styled(Input.Search)`
padding: 20px 0;
`;

const onChange = (refine: any, value: any) => {
refine(value);
Expand All @@ -23,10 +17,9 @@ const SearchBox = ({ refine, currentRefinement }: any) => {
};

return (
<StyledInput
<input
placeholder="Search speakers by their name, tags and social networks"
onChange={onChangeDebounced}
size="large"
value={state.value}
/>
);
Expand Down
40 changes: 0 additions & 40 deletions components/SpeakersList.tsx

This file was deleted.

76 changes: 37 additions & 39 deletions components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
import { Icon } from 'antd';
import React from 'react';
import styled from 'styled-components';
import { FC } from 'react';

interface Props {
href: string;
icon: string;
}

const ButtonWrapper = styled.a`
width: 40px;
padding: 0;
font-size: 18px;
border-radius: 50%;
height: 40px;
line-height: 38px;
display: inline-block;
font-weight: 400;
text-align: center;
touch-action: manipulation;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
user-select: none;
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
position: relative;
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
color: rgba(0, 0, 0, 0.65);
background-color: #fff;
border-color: #d9d9d9;
// const ButtonWrapper = styled.a`
// width: 40px;
// padding: 0;
// font-size: 18px;
// border-radius: 50%;
// height: 40px;
// line-height: 38px;
// display: inline-block;
// font-weight: 400;
// text-align: center;
// touch-action: manipulation;
// cursor: pointer;
// background-image: none;
// border: 1px solid transparent;
// white-space: nowrap;
// user-select: none;
// transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
// position: relative;
// box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
// color: rgba(0, 0, 0, 0.65);
// background-color: #fff;
// border-color: #d9d9d9;

&:hover,
&:focus {
color: #40a9ff;
background-color: #fff;
border-color: #40a9ff;
}
// &:hover,
// &:focus {
// color: #40a9ff;
// background-color: #fff;
// border-color: #40a9ff;
// }

&:last-child {
margin-right: 0;
}
`;
// &:last-child {
// margin-right: 0;
// }
// `;

const Button = ({ href, icon }: Props) => (
<ButtonWrapper href={href} target="_blank" rel="noopener noreferrer">
<Icon type={icon} />
</ButtonWrapper>
const Button: FC<Props> = ({ href, icon }) => (
<a href={href} target="_blank" rel="noopener noreferrer">
{/* <Icon type={icon} /> */}
</a>
);

export default Button;
3 changes: 3 additions & 0 deletions components/button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Button from './Button';

export default Button;
Loading

0 comments on commit cdb86cf

Please sign in to comment.