Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
8ce5366e
Commit
8ce5366e
authored
5 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
テーマ関係
parent
bfcda7cc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/client/theme.ts
+17
-9
17 additions, 9 deletions
src/client/theme.ts
src/docs/theme.ja-JP.md
+74
-0
74 additions, 0 deletions
src/docs/theme.ja-JP.md
with
91 additions
and
9 deletions
src/client/theme.ts
+
17
−
9
View file @
8ce5366e
...
...
@@ -27,7 +27,7 @@ export const builtinThemes = [
require
(
'
./themes/danboard.json5
'
),
require
(
'
./themes/olive.json5
'
),
require
(
'
./themes/tweetdeck.json5
'
),
];
]
as
Theme
[
];
let
timeout
=
null
;
...
...
@@ -66,16 +66,21 @@ export function applyTheme(theme: Theme, persist = true) {
}
}
function
compile
(
theme
:
Theme
):
{
[
key
:
string
]:
string
}
{
function
getColor
(
code
:
string
):
tinycolor
.
Instance
{
// ref
if
(
code
[
0
]
==
'
@
'
)
{
return
getColor
(
theme
.
props
[
code
.
substr
(
1
)]);
function
compile
(
theme
:
Theme
):
Record
<
string
,
string
>
{
function
getColor
(
val
:
string
):
tinycolor
.
Instance
{
// ref (prop)
if
(
val
[
0
]
===
'
@
'
)
{
return
getColor
(
theme
.
props
[
val
.
substr
(
1
)]);
}
// ref (const)
else
if
(
val
[
0
]
===
'
$
'
)
{
return
getColor
(
theme
.
props
[
val
]);
}
// func
if
(
code
[
0
]
==
'
:
'
)
{
const
parts
=
code
.
split
(
'
<
'
);
else
if
(
val
[
0
]
==
=
'
:
'
)
{
const
parts
=
val
.
split
(
'
<
'
);
const
func
=
parts
.
shift
().
substr
(
1
);
const
arg
=
parseFloat
(
parts
.
shift
());
const
color
=
getColor
(
parts
.
join
(
'
<
'
));
...
...
@@ -87,12 +92,15 @@ function compile(theme: Theme): { [key: string]: string } {
}
}
return
tinycolor
(
code
);
// other case
return
tinycolor
(
val
);
}
const
props
=
{};
for
(
const
[
k
,
v
]
of
Object
.
entries
(
theme
.
props
))
{
if
(
k
.
startsWith
(
'
$
'
))
continue
;
// ignore const
props
[
k
]
=
genValue
(
getColor
(
v
));
}
...
...
This diff is collapsed.
Click to expand it.
src/docs/theme.ja-JP.md
0 → 100644
+
74
−
0
View file @
8ce5366e
# テーマ
テーマを設定して、Misskeyクライアントの見た目を変更できます。
## テーマの設定
設定 > テーマ
## テーマを作成する
テーマコードはJSON5で記述されたテーマオブジェクトです。
テーマは以下のようなオブジェクトです。
```
js
{
id
:
'
17587283-dd92-4a2c-a22c-be0637c9e22a
'
,
name
:
'
Danboard
'
,
author
:
'
syuilo
'
,
base
:
'
light
'
,
props
:
{
accent
:
'
rgb(218, 141, 49)
'
,
bg
:
'
rgb(218, 212, 190)
'
,
fg
:
'
rgb(115, 108, 92)
'
,
panel
:
'
rgb(236, 232, 220)
'
,
renote
:
'
rgb(100, 152, 106)
'
,
link
:
'
rgb(100, 152, 106)
'
,
mention
:
'
@accent
'
,
hashtag
:
'
rgb(100, 152, 106)
'
,
header
:
'
rgba(239, 227, 213, 0.75)
'
,
navBg
:
'
rgb(216, 206, 182)
'
,
inputBorder
:
'
rgba(0, 0, 0, 0.1)
'
,
},
}
```
*
`id`
... テーマの一意なID。UUIDをおすすめします。
*
`name`
... テーマ名
*
`author`
... テーマの作者
*
`desc`
... テーマの説明(オプション)
*
`base`
... 明るいテーマか、暗いテーマか
*
`light`
にすると明るいテーマになり、
`dark`
にすると暗いテーマになります。
*
テーマはここで設定されたベーステーマを継承します。
*
`props`
... テーマのスタイル定義。これから説明します。
### テーマのスタイル定義
`props`
下にはテーマのスタイルを定義します。
キーがCSSの変数名になり、バリューで中身を指定します。
なお、この
`props`
オブジェクトはベーステーマから継承されます。
ベーステーマは、このテーマの
`base`
が
`light`
なら
[
_light.json5
](
https://github.com/syuilo/misskey/blob/develop/src/client/themes/_light.json5
)
で、
`dark`
なら
[
_dark.json5
](
https://github.com/syuilo/misskey/blob/develop/src/client/themes/_dark.json5
)
です。
つまり、このテーマ内の
`props`
に
`panel`
というキーが無くても、そこにはベーステーマの
`panel`
があると見なされます。
#### バリューで使える構文
*
16進数で表された色
*
例:
`#00ff00`
*
`rgb(r, g, b)`
形式で表された色
*
例:
`rgb(0, 255, 0)`
*
`rgb(r, g, b, a)`
形式で表された透明度を含む色
*
例:
`rgba(0, 255, 0, 0.5)`
*
他のキーの値の参照
*
`@{キー名}`
と書くと他のキーの値の参照になります。
`{キー名}`
は参照したいキーの名前に置き換えます。
*
例:
`@panel`
*
定数(後述)の参照
*
`${定数名}`
と書くと定数の参照になります。
`{定数名}`
は参照したい定数の名前に置き換えます。
*
例:
`$main`
*
関数(後述)
*
`:{関数名}<{引数}<{色}`
#### 定数
「CSS変数として出力はしたくないが、他のCSS変数の値として使いまわしたい」値があるときは、定数を使うと便利です。
キー名を
`$`
で始めると、そのキーはCSS変数として出力されません。
#### 関数
wip
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment