Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
835f9bef
Commit
835f9bef
authored
Mar 13, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate theme to TypeScript
parent
795a14e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
theme.ts
src/sidebar/helpers/theme.ts
+13
-16
No files found.
src/sidebar/helpers/theme.
j
s
→
src/sidebar/helpers/theme.
t
s
View file @
835f9bef
/**
* @typedef {import('../../types/config').ThemeProperty} ThemeProperty
*/
import
type
{
ThemeProperty
}
from
'../../types/config'
;
/** @type {Record<ThemeProperty, string>} */
const
supportedThemeProperties
=
{
const
supportedThemeProperties
:
Record
<
ThemeProperty
,
string
>
=
{
accentColor
:
'color'
,
appBackgroundColor
:
'backgroundColor'
,
ctaBackgroundColor
:
'backgroundColor'
,
...
...
@@ -14,10 +11,10 @@ const supportedThemeProperties = {
/**
* Subset of the config from the host page which includes theme configuration.
*
* @typedef Settings
* @prop {Record<ThemeProperty,string>} [branding]
*/
type
Settings
=
{
branding
?:
Record
<
ThemeProperty
,
string
>
;
};
/**
* Return a React `style` object suitable for use as the value of the `style`
...
...
@@ -35,11 +32,9 @@ const supportedThemeProperties = {
*
* See https://reactjs.org/docs/dom-elements.html#style
*
* @param {ThemeProperty[]} themeProperties -
* Which of the supported theme properties should have applied rules in the `style`
* object
* @param {Settings} settings
* @return {Record<string,string>} - Object that can be passed as the `style` prop
* @param themeProperties - Which of the supported theme properties should have
* applied rules in the `style` object
* @return Object that can be passed as the `style` prop
*
* @example
* let themeProperties = ['accentColor', 'ctaTextColor', 'foo'];
...
...
@@ -52,9 +47,11 @@ const supportedThemeProperties = {
* // only one of those has a value in the `settings` object, so:
* applyTheme(themeProperties, settings); // -> { color: '#ffc '}
*/
export
function
applyTheme
(
themeProperties
,
settings
)
{
/** @type {Record<string,string>} */
const
style
=
{};
export
function
applyTheme
(
themeProperties
:
ThemeProperty
[],
settings
:
Settings
):
Record
<
string
,
string
>
{
const
style
:
Record
<
string
,
string
>
=
{};
if
(
!
settings
.
branding
)
{
return
style
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment