From 50b40cc0350831e81f2361489fba21da1c9813a6 Mon Sep 17 00:00:00 2001 From: Artyom Date: Fri, 9 Jun 2017 16:00:33 +0200 Subject: [PATCH] [GD-11] Implement the category status banner --- front/src/components/Category.js | 33 ++++++++++++++++++++++++++++++-- front/src/types.js | 9 ++++++--- src/Guide/Handlers.hs | 1 + src/Guide/Types/Core.hs | 5 ++++- static/markup.css | 9 --------- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/front/src/components/Category.js b/front/src/components/Category.js index 98c3e12..9bf1f9d 100644 --- a/front/src/components/Category.js +++ b/front/src/components/Category.js @@ -3,9 +3,38 @@ import React, { Component } from 'react'; import * as T from '../types'; import { fetchData, extractUid, mkLink } from '../utils/index'; -import { If } from 'jsx-control-statements'; +import { If, Choose, When } from 'jsx-control-statements'; import { Item } from './Item'; + +const CategoryStatusBanner = (props : T.Cat) => { + const stub = "This category is a stub, contributions are welcome!"; + const wip = "This category is a work in progress"; + function banner(text: string) { + return ( +
+ {text} + +
+ ) + } + return ( + + { banner(stub) } + { banner(wip) } +
+ + ) +} + class Category extends Component { state: { cat : T.Cat @@ -36,6 +65,7 @@ class Category extends Component { edit delete +
@@ -59,7 +89,6 @@ class Category extends Component { box-sizing: border-box; line-height: 19.2px; width: 762px; - height: 24px; } .category-info span { diff --git a/front/src/types.js b/front/src/types.js index 25def2e..e64e820 100644 --- a/front/src/types.js +++ b/front/src/types.js @@ -49,10 +49,13 @@ export type Item = { cons : Array }; +export type CatStatus = "Stub" | "WIP" | "Finished"; + export type Cat = { uid: string, - title : string, + title: string, group: string, - description : Description, - items : Array + status: CatStatus, + description: Description, + items: Array }; diff --git a/src/Guide/Handlers.hs b/src/Guide/Handlers.hs index dd649b7..790de15 100644 --- a/src/Guide/Handlers.hs +++ b/src/Guide/Handlers.hs @@ -92,6 +92,7 @@ apiMethods = Spock.subcomponent "api" $ do , "group" A..= (cat^.group_) , "description" A..= (cat^.notes) , "items" A..= (cat^.items) + , "status" A..= (cat^.status) ] json jsonCat diff --git a/src/Guide/Types/Core.hs b/src/Guide/Types/Core.hs index fcbe391..0e52d58 100644 --- a/src/Guide/Types/Core.hs +++ b/src/Guide/Types/Core.hs @@ -199,7 +199,10 @@ data CategoryStatus deriveSafeCopySimple 2 'extension ''CategoryStatus instance A.ToJSON CategoryStatus where - toJSON = A.genericToJSON A.defaultOptions + toJSON = \case + CategoryStub -> A.toJSON ("Stub" :: Text) + CategoryWIP -> A.toJSON ("WIP" :: Text) + CategoryFinished -> A.toJSON ("Finished" :: Text) data CategoryStatus_v1 = CategoryStub_v1 diff --git a/static/markup.css b/static/markup.css index f676763..a0d9f83 100644 --- a/static/markup.css +++ b/static/markup.css @@ -43,12 +43,3 @@ a:link {color: #008ACE; text-decoration: none;} a:visited {color: #B40EB4; text-decoration: none;} a:hover {text-decoration: underline;} a:active {text-decoration: underline;} - -.category-status-banner { - background-color: #FFF694; - text-align: center; - border: 2px solid #202020; - padding: 0.5em; - margin-left: 10%; - margin-right: 10%; -}