From 372e016e3d6354f509fabe3c57bf430f34b2af26 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 22 Sep 2021 15:55:45 +0700 Subject: [PATCH] added placeholders for boris stats --- .../boris/BorisStatsBackend/index.tsx | 107 +++++++++++------- .../BorisStatsBackend/styles.module.scss | 14 +-- .../placeholders/Placeholder/index.tsx | 4 +- .../Placeholder/styles.module.scss | 2 + src/redux/boris/reducer.ts | 25 +++- 5 files changed, 104 insertions(+), 48 deletions(-) diff --git a/src/components/boris/BorisStatsBackend/index.tsx b/src/components/boris/BorisStatsBackend/index.tsx index d4ca7916..e3a034e3 100644 --- a/src/components/boris/BorisStatsBackend/index.tsx +++ b/src/components/boris/BorisStatsBackend/index.tsx @@ -8,64 +8,95 @@ interface IProps { stats: IBorisState['stats']; } -const BorisStatsBackend: FC = ({ stats }) => { - if (stats.is_loading) - return ( +const Row: FC<{ isLoading: boolean }> = ({ isLoading, children }) => ( +
  • + {isLoading ? ( <> -
    - -
    + + - ); + ) : ( + children + )} +
  • +); - if (!stats.backend) return null; +const BorisStatsBackend: FC = ({ stats: { is_loading, backend } }) => { + // const is_loading = true; + + if (!backend && !is_loading) { + return null; + } return (
    -
    Юнитс
    +
    + + Юнитс + +
      -
    • - В сознании {stats.backend.users.alive} -
    • + + В сознании + {backend.users.alive} + -
    • - Криокамера {stats.backend.users.total - stats.backend.users.alive} -
    • + + Криокамера + {backend.users.total - backend.users.alive} +
    -
    Контент
    +
    + + Контент + +
      -
    • - Фотографии {stats.backend.nodes.images} -
    • + + Фотографии + {backend.nodes.images} + -
    • - Письма {stats.backend.nodes.texts} -
    • + + Письма + {backend.nodes.texts} + -
    • - Видеозаписи {stats.backend.nodes.videos} -
    • + + Видеозаписи + {backend.nodes.videos} + -
    • - Аудиозаписи {stats.backend.nodes.audios} -
    • + + Аудиозаписи + {backend.nodes.audios} + -
    • - Комментарии {stats.backend.comments.total} -
    • + + Комментарии + {backend.comments.total} +
    -
    Сторедж
    +
    + + Сторедж + +
    +
      -
    • - Файлы {stats.backend.files.count} -
    • -
    • - На диске {sizeOf(stats.backend.files.size)} -
    • + + Файлы + {backend.files.count} + + + + На диске + {sizeOf(backend.files.size)} +
    ); diff --git a/src/components/boris/BorisStatsBackend/styles.module.scss b/src/components/boris/BorisStatsBackend/styles.module.scss index 073813f8..16fe4a3c 100644 --- a/src/components/boris/BorisStatsBackend/styles.module.scss +++ b/src/components/boris/BorisStatsBackend/styles.module.scss @@ -1,18 +1,18 @@ @import "src/styles/variables"; +.value { + float: right; + color: white; + font: $font_12_semibold; + line-height: 24px; +} + .wrap { ul { font: $font_12_regular; line-height: 24px; text-transform: uppercase; - span { - float: right; - color: white; - font: $font_12_semibold; - line-height: 24px; - } - li { border-bottom: 1px solid #333333; color: #aaaaaa; diff --git a/src/components/placeholders/Placeholder/index.tsx b/src/components/placeholders/Placeholder/index.tsx index 2686f21d..b2893730 100644 --- a/src/components/placeholders/Placeholder/index.tsx +++ b/src/components/placeholders/Placeholder/index.tsx @@ -8,6 +8,7 @@ export interface PlaceholderProps { color?: string; active?: boolean; loading?: boolean; + className?: string; } const Placeholder: FC = ({ @@ -17,10 +18,11 @@ const Placeholder: FC = ({ active, children, loading = true, + className, }) => { return active ? (
    ) : ( diff --git a/src/components/placeholders/Placeholder/styles.module.scss b/src/components/placeholders/Placeholder/styles.module.scss index 1492f8d9..01a43c44 100644 --- a/src/components/placeholders/Placeholder/styles.module.scss +++ b/src/components/placeholders/Placeholder/styles.module.scss @@ -9,6 +9,7 @@ opacity: 0.05; } } + .placeholder { height: 1em; width: 120px; @@ -16,6 +17,7 @@ border-radius: 1em; position: relative; overflow: hidden; + display: inline-flex; &::after { content: ' '; diff --git a/src/redux/boris/reducer.ts b/src/redux/boris/reducer.ts index 8cfebc20..6011418d 100644 --- a/src/redux/boris/reducer.ts +++ b/src/redux/boris/reducer.ts @@ -32,18 +32,39 @@ export type IStatBackend = { export interface BorisUsageStats { git: Partial[]; issues: IGithubIssue[]; - backend?: IStatBackend; + backend: IStatBackend; is_loading: boolean; } export type IBorisState = Readonly<{ stats: BorisUsageStats; }>; +const initialBackendStats: IStatBackend = { + users: { + total: 0, + alive: 0, + }, + nodes: { + images: 0, + audios: 0, + videos: 0, + texts: 0, + total: 0, + }, + comments: { + total: 0, + }, + files: { + count: 0, + size: 0, + }, +}; + const BORIS_INITIAL_STATE: IBorisState = { stats: { git: [], issues: [], - backend: undefined, + backend: initialBackendStats, is_loading: false, }, };