@@ -18,6 +18,12 @@ const THEME_LIST: { label: string; key: Theme }[] = [
1818 { label : "DARK" , key : "dark" } ,
1919] ;
2020
21+ const DEFAULT_CSS = `.gt-container {
22+ --gt-color-main: #059669;
23+ --gt-color-main-lighter: #10b981;
24+ }` ;
25+ const GITALK_CUSTOM_CSS_KEY = "GITALK_CUSTOM_CSS" ;
26+
2127const GITALK_BASE_OPTIONS : GitalkProps = import . meta. env . PROD
2228 ? {
2329 clientID : "Ov23lizwQOGBomnxr5j1" ,
@@ -48,9 +54,12 @@ const I18N_LANGS = Object.keys(i18nMap) as Lang[];
4854const App = ( ) => {
4955 const [ issuesPage , setIssuesPage ] = useState < number > ( 1 ) ;
5056 const [ issuesLoaded , setIssuesLoaded ] = useState < boolean > ( false ) ;
57+ const [ issueNumber , setIssueNumber ] = useState < number > ( ) ;
5158
5259 const [ theme , setTheme ] = useState < Theme > ( "light" ) ;
53- const [ issueNumber , setIssueNumber ] = useState < number > ( ) ;
60+ const [ css , setCSS ] = useState < string > (
61+ localStorage . getItem ( GITALK_CUSTOM_CSS_KEY ) ?? DEFAULT_CSS ,
62+ ) ;
5463
5564 const [ options , setOptions ] = useState <
5665 Omit <
@@ -168,6 +177,23 @@ const App = () => {
168177 location . href = url . toString ( ) ;
169178 } ;
170179
180+ const onResetCSS = ( ) => {
181+ document . getElementById ( GITALK_CUSTOM_CSS_KEY ) ?. remove ( ) ;
182+
183+ setCSS ( DEFAULT_CSS ) ;
184+ } ;
185+
186+ const onSetCSS = ( cssString : string ) => {
187+ document . getElementById ( GITALK_CUSTOM_CSS_KEY ) ?. remove ( ) ;
188+
189+ const style = document . createElement ( "style" ) ;
190+ style . id = GITALK_CUSTOM_CSS_KEY ;
191+ style . textContent = cssString ;
192+ document . head . appendChild ( style ) ;
193+
194+ localStorage . setItem ( GITALK_CUSTOM_CSS_KEY , cssString ) ;
195+ } ;
196+
171197 return (
172198 < div
173199 style = { {
@@ -219,6 +245,32 @@ const App = () => {
219245 { themeLabel }
220246 </ button >
221247 ) ) }
248+
249+ < div style = { { width : "100%" , marginTop : 12 } } >
250+ < textarea
251+ style = { {
252+ width : "calc(100% - 16px)" ,
253+ minHeight : 100 ,
254+ resize : "vertical" ,
255+ padding : 8 ,
256+ } }
257+ placeholder = "Custom your styles"
258+ value = { css }
259+ onChange = { ( e ) => setCSS ( e . target . value ) }
260+ />
261+ < div style = { { width : "100%" , marginTop : 6 , textAlign : "end" } } >
262+ < button
263+ className = "small"
264+ style = { { marginRight : 8 } }
265+ onClick = { onResetCSS }
266+ >
267+ Reset
268+ </ button >
269+ < button className = "primary small" onClick = { ( ) => onSetCSS ( css ) } >
270+ Confirm
271+ </ button >
272+ </ div >
273+ </ div >
222274 </ div >
223275 </ section >
224276
0 commit comments