Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOX-138 - card list #38

Merged
merged 33 commits into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0ab54da
feat(pages/search): adds search page, adds ability to search
OlegBrony Jun 6, 2021
945d09c
fix(pages/search): fixes empty query
OlegBrony Jun 6, 2021
46f140f
fix(pages/search): plural function
OlegBrony Jun 6, 2021
eda2eb8
fix(pages): suggestions from review
OlegBrony Jun 18, 2021
bfb7e0a
fix(app): use-query package
OlegBrony Jun 18, 2021
8e8fbee
feat(pages): search page
OlegBrony Jun 22, 2021
d722ecf
feat(ui/templates): header - changes color of button
OlegBrony Jun 24, 2021
574ab85
Merge branch 'master' into feat/61-add-search-page
OlegBrony Jun 24, 2021
3e02cd5
fix(app): review suggestions
OlegBrony Jun 24, 2021
9df0245
fix(app): fix reflext and package
OlegBrony Jun 25, 2021
e10de1a
Merge branch 'master' into feat/61-add-search-page
OlegBrony Jun 25, 2021
bce9848
fix(app): fixed ssr for reflect in one place
OlegBrony Jun 25, 2021
c92f2df
Merge branch 'master' into feat/61-add-search-page
OlegBrony Jun 28, 2021
ba9e97f
fix(app): regenerate yarn lock
OlegBrony Jun 28, 2021
0129c0c
fix(app): fixes letter dublicates in user search
OlegBrony Jun 28, 2021
e6dc99d
fix(features): card preview - make clickable
OlegBrony Jun 30, 2021
8287c51
fix(features): card preview - make clickable
OlegBrony Jun 30, 2021
9e44f4a
Merge remote-tracking branch 'origin/feat/138-search' into feat/138-s…
OlegBrony Jun 30, 2021
e31424a
Merge branch 'master' into feat/138-search-fixes-card-list
OlegBrony Jun 30, 2021
4fb3158
fix(app): regenerate lock
OlegBrony Jun 30, 2021
5fce458
fix(app): remove package lock
OlegBrony Jun 30, 2021
6f8216b
fix(features): card list
OlegBrony Jul 1, 2021
e59f048
feat(api): adds simulation from api - adds reaction to search params
OlegBrony Jul 5, 2021
9f112f5
fix(app): changes from review
OlegBrony Jul 5, 2021
3b14190
Merge branch 'master' into feat/138-search-fixes-card-list
OlegBrony Jul 5, 2021
10f11d4
fix(app): review changes
OlegBrony Jul 5, 2021
a923c00
fix(app): review changes
OlegBrony Jul 5, 2021
fffdb7c
fix(app): review
OlegBrony Jul 5, 2021
559894e
fix(app): fixed autocomplete from tsconfig|styles (glogal props)
OlegBrony Jul 6, 2021
d7ab358
style: move focus funcs to hook
OlegBrony Jul 6, 2021
b6fd804
fix(app): review
OlegBrony Jul 9, 2021
61fdd5e
fix(app): fixes card click on button
OlegBrony Jul 9, 2021
7b96bca
fix(app): adds todo
OlegBrony Jul 9, 2021
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"cross-env": "^7.0.2",
"cz-conventional-changelog": "3.0.2",
"cz-customizable": "^6.2.1",
"eslint": "^6.0.0",
"eslint": "6.8.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.22.0",
"glob": "^7.1.6",
Expand Down
5 changes: 3 additions & 2 deletions src/api/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import type { Card, User } from '../types';
// NOTE: По сути будет использоваться только на клиенте, поэтому импорчу напрямую
import { requestClient } from '../request/client';

// FIXME: Удалю модуль позднее, после генерации через OpenApi
// Но для этого надо поправить саму схему
// FIXME:
// Удалю модуль позднее, после генерации через OpenApi
// Но для этого надо поправить саму схему

// TODO: bind with /api/request
// TODO: autogen later by openapi-generator
Expand Down
12 changes: 6 additions & 6 deletions src/api/mock/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const cards: Card[] = [
},
{
id: '2',
title: `Effector: sample vs forward`,
title: `Effector: sample vs forward, Effector: sample vs forward`,
content: `Sample: This method can be used for linking two nodes, resulting the third one, which will fire only upon clock node trigger.\nForward: Method to create connection between units in a declarative way. Sends updates from one set of units to another`,
author: viewer,
createdAt: '2021-01-04T05:03:00.000Z',
Expand All @@ -161,13 +161,13 @@ export const cards: Card[] = [
},
{
id: '3',
title: `Effects sequence`,
title: `Effects sequence, Effects sequence, Effects sequence`,
content: `We'll need it when second request to the server requires resolved data from the first one
\`\`\`
import ReactDOM from 'react-dom'

const getAllId = createEffect({handler: async () => [1, 2, 3]})

const getPostsByIds = createEffect({
handler: ids => Promise.all(ids.map(
async id => {
Expand All @@ -179,12 +179,12 @@ export const cards: Card[] = [
}
))
})

forward({
from: getAllId.done.map(({result}) => result),
to: getPostsByIds,
})

const postGroups = createStore([])
.on(getPostsByIds.done, (list, {result}) => [
...list,
Expand Down Expand Up @@ -212,7 +212,7 @@ export const cards: Card[] = [
},
{
id: '5',
title: `Effector live comparsion`,
title: `Stop using Effector`,
OlegBrony marked this conversation as resolved.
Show resolved Hide resolved
content: `Effector is a brand new reactive state manager. Its ambitious team aims to solve all the problems that existing solutions have. Writing the core of the library from scratch took several attempts across six months, and recently the team released the first stable release.

In this article, I will show why I prefer using Effector for my new projects instead of other state managers. Let's get started with the Effector API.`,
Expand Down
37 changes: 31 additions & 6 deletions src/api/mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { Model, belongsTo, createServer, hasMany } from 'miragejs';

import type { User } from '../types';
import type { Card, User } from '../types';
import { cards, users, viewer } from './fixtures';

/** little shortcut for search */
function hasIncluding({
including,
query,
}: {
including?: string;
query: string;
}) {
if (!including) return false;
return including.toLowerCase().includes(query);
}
OlegBrony marked this conversation as resolved.
Show resolved Hide resolved
/**
* Mock-api server for internal development
* @see https://cardbox.github.io/backend/api-internal/index.html
Expand Down Expand Up @@ -39,11 +50,26 @@ export function runMockServer() {
routes() {
this.namespace = 'api';

this.post('/search.results', (schema) => {
// TODO: add search-query param processing
this.post('/search.results', (schema, req) => {
const { query } = JSON.parse(req.requestBody);
const users = schema.db.users.where((user: User) => {
return (
hasIncluding({ including: user.username, query }) ||
hasIncluding({ including: user.firstName, query }) ||
hasIncluding({ including: user.lastName, query })
);
});

const cards = schema.db.cards.where((card: Card) => {
return (
hasIncluding({ including: card.title, query }) ||
hasIncluding({ including: card.content, query })
);
});

return {
users: schema.db.users,
cards: schema.db.cards,
users,
cards,
};
});

Expand Down Expand Up @@ -106,6 +132,5 @@ export function runMockServer() {
});
},
});

return instance;
}
12 changes: 2 additions & 10 deletions src/app/application.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import 'react-tabs/style/react-tabs.css';
import './custom-props.css';

import * as React from 'react';
import styled, { createGlobalStyle } from 'styled-components';
Expand Down Expand Up @@ -26,17 +26,9 @@ const Globals = createGlobalStyle`
padding: 0;
font-family: sans-serif;
}

:root {
--wizard500: #4231FF;
--wizard300: #B6AFFF;
--wizard100: #F7F6FF;

--gray100: #FBFAFB;
}
`;

export const Application: React.FC<Props> = ({ root }) => (
export const Application = ({ root }: Props) => (
<QueryParamProvider ReactRouterRoute={Route}>
<Provider value={root}>
<Container>
Expand Down
14 changes: 14 additions & 0 deletions src/app/custom-props.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:root {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потом бы в vars.css или variables.css переименовал, но некритично)

--wizard500: #4231ff;
--wizard300: #b6Afff;
--wizard100: #f7f6ff;

--gray100: #fbfafb;

/* backgrounds */
--bnw100: #fbfafb;
--bnw200: #eeeef1;
--bnw0: #fff;

--box-shadow-1: 0px 3px 9px #ebebeb;
}
8 changes: 6 additions & 2 deletions src/entities/card/organisms/card-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import styled from 'styled-components';
import type { Card } from '@box/api';
import { SkeletonGroup } from '@box/ui';
import { useFocus } from '@box/lib/use-focus';

import { CardPreview } from './card-preview';

Expand All @@ -11,19 +12,22 @@ interface Props {
loading?: boolean;
}

export const CardList: React.FC<Props> = ({ cards, getHref, loading }) => {
export const CardList = ({ cards, getHref, loading }: Props) => {
const { focusItemChanged, containerRef } = useFocus();

if (loading) {
return <SkeletonGroup amount={4} />;
}

return (
<Container>
<Container ref={containerRef}>
{cards.map((card, i) => (
<CardPreview
key={card.id}
card={card}
isCardInFavorite={i % 2 === 0}
href={getHref?.(card)}
focusItemChanged={focusItemChanged}
/>
))}
</Container>
Expand Down
Loading