2
2
import ReactMarkdown from "react-markdown" ;
3
3
4
4
// Hooks
5
-
5
+ import { useState } from "react"
6
6
7
7
// Types
8
-
9
8
import React , { CSSProperties , FC } from "react"
10
-
11
-
12
- // Styles
13
9
import { ChallDropProps } from "./ChallDrop" ;
14
-
10
+ import ChallDropFlagInput from "./ChallDropFlagInput" ;
15
11
16
12
// Utils
17
13
import remarkGfm from "remark-gfm" ;
18
- import ChallDropFlagInput from "./ChallDropFlagInput" ;
19
14
20
15
21
16
const ListItem = ( { item, className, style } : { item : string , style ?: CSSProperties , className ?: string } ) => (
@@ -39,10 +34,21 @@ const EnglishList = ({ items: list, style, className }: { items: string[], style
39
34
</ > ;
40
35
}
41
36
37
+ const Hint = ( { value } : { value : string } ) => {
38
+ const [ revealed , setRevealed ] = useState ( false ) ;
39
+ return < div
40
+ className = { `
41
+ block transition-all py-1 px-2 rounded-lg mb-2 select-none
42
+ ${ revealed ? "text-white bg-slate-800 cursor-default" : "text-transparent bg-slate-900 cursor-pointer" } ` }
43
+ onClick = { ( ) => setRevealed ( true ) } >
44
+ { value }
45
+ </ div > ;
46
+ } ;
47
+
42
48
const BodyMeta : FC < Pick <
43
49
ChallDropProps [ "metadata" ] ,
44
- "solveCount" | "categories" | "points" | "tags" | "authors"
45
- > > = ( { solveCount, categories, points, authors } ) => (
50
+ "solveCount" | "categories" | "points" | "tags" | "authors" | "hints"
51
+ > > = ( { solveCount, categories, points, authors, hints } ) => (
46
52
< div className = "w-full p-5 pt-2 pl-0 ml-auto flex flex-col"
47
53
style = { { gridArea : "meta" } } >
48
54
< div className = "py-3" >
@@ -53,6 +59,10 @@ const BodyMeta: FC<Pick<
53
59
< span className = "py-1.5" >
54
60
{ solveCount . toLocaleString ( 'en-US' , { maximumFractionDigits : 0 } ) } { solveCount === 1 ? "solve" : "solves" }
55
61
</ span >
62
+ < div className = "py-3" >
63
+ < h4 className = "font-medium text-base mb-1" > Hints:</ h4 >
64
+ { hints . map ( hint => < Hint value = { hint } /> ) }
65
+ </ div >
56
66
< div className = "py-1.5 mb-auto" >
57
67
By < EnglishList className = "font-mono text-chall-author-name-color" items = { authors } />
58
68
</ div >
@@ -106,7 +116,7 @@ const Links: FC<{ urls: string[], type: LinkType }> = ({ urls, type }) => {
106
116
} ;
107
117
108
118
const ChallDropBody : FC < ChallDropProps & { open : boolean } > = ( {
109
- metadata : { solveCount, categories, points, tags, desc, links, authors } ,
119
+ metadata : { solveCount, categories, points, tags, desc, links, authors, hints } ,
110
120
solved,
111
121
submission : { challId, userId, teamId }
112
122
} ) => (
@@ -139,7 +149,7 @@ const ChallDropBody: FC<ChallDropProps & { open: boolean }> = ({
139
149
</ div >
140
150
</ div >
141
151
142
- < BodyMeta { ...{ solveCount, solved, points, tags, categories, links, authors } } />
152
+ < BodyMeta { ...{ solveCount, solved, points, tags, categories, links, authors, hints } } />
143
153
144
154
< ChallDropFlagInput { ...{ challId, teamId, userId } } />
145
155
0 commit comments