Rework themes support

- Add theme settings for figures.
- Settings for styles are now in it own class and
  ThemeSettings are wrapping those.
- Prefixed formatting string to have `style-` prefix.
- Templates can now use added `figures` dictionary which
  is resolved per activated theme.
- Create `dump` theme.
- New `ThemeActive` interface where default impl uses dump
  theme if `CI` or `NO_COLOR` env is set.
- Rework existing templates.
- Fixes #442
This commit is contained in:
Janne Valkealahti
2022-06-10 09:11:30 +01:00
parent fa65a2308e
commit 073cd8562c
27 changed files with 807 additions and 256 deletions

View File

@@ -12,20 +12,20 @@ message(model) ::= <%
// info section after '? xxx'
info(model) ::= <%
<if(model.defaultValue)>
<("(Y/n)"); format="item-disabled">
<("(Y/n)"); format="style-item-disabled">
<else>
<("(y/N)"); format="item-disabled">
<("(y/N)"); format="style-item-disabled">
<endif>
%>
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
<({<figures.questionMark>}); format="style-list-value"> <model.name; format="style-title">
>>
// component result
result(model) ::= <<
<question_name(model)> <model.resultValue; format="value">
<question_name(model)> <model.resultValue; format="style-value">
>>
// component is running

View File

@@ -1,30 +1,30 @@
// used to select style if item is selected/unselected
selected_style(flag) ::= <%
<if(flag)>item-selected<else>item-unselected<endif>
<if(flag)>style-item-selected<else>style-item-unselected<endif>
%>
// selector rows
select_item(item) ::= <%
<if(item.onrow)>
<("> "); format="item-selector">
<({<figures.rightPointingQuotation> }); format="style-item-selector">
<else>
<(" ")>
<endif>
<if(item.enabled)>
<if(item.selected)>
<("[x]"); format=selected_style(item.selected)> <item.name>
<({<figures.checkboxOn> }); format=selected_style(item.selected)> <item.name>
<else>
<("[ ]"); format=selected_style(item.selected)> <item.name>
<({<figures.checkboxOff> }); format=selected_style(item.selected)> <item.name>
<endif>
<else>
<("[ ]"); format="item-disabled"> <item.name; format="item-disabled">
<({<figures.checkboxOff> }); format="style-item-disabled"> <item.name; format="style-item-disabled">
<endif>
%>
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
<({<figures.questionMark>}); format="style-list-value"> <model.name; format="style-title">
>>
// within info section, dedicated instructions for user
@@ -48,7 +48,7 @@ comma_delimited(values) ::= <%
// component result
result(model) ::= <<
<question_name(model)> <(comma_delimited(model.values)); format="value">
<question_name(model)> <(comma_delimited(model.values)); format="style-value">
>>
// component is running

View File

@@ -1,11 +1,11 @@
// message
message(model) ::= <%
<if(model.message && model.hasMessageLevelError)>
<(">>>"); format="level-error"> <model.message; format="level-error">
<({<figures.error>}); format="style-level-error"> <model.message; format="style-level-error">
<elseif(model.message && model.hasMessageLevelWarn)>
<(">>"); format="level-warn"> <model.message; format="level-warn">
<({<figures.warning>}); format="style-level-warn"> <model.message; format="style-level-warn">
<elseif(model.message && model.hasMessageLevelInfo)>
<(">"); format="level-info"> <model.message; format="level-info">
<({<figures.info>}); format="style-level-info"> <model.message; format="style-level-info">
<endif>
%>
@@ -18,12 +18,12 @@ info(model) ::= <%
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
<({<figures.questionMark>}); format="style-list-value"> <model.name; format="style-title">
>>
// component result
result(model) ::= <<
<question_name(model)> <model.resultValue; format="value">
<question_name(model)> <model.resultValue; format="style-value">
>>
// component is running

View File

@@ -1,7 +1,7 @@
// selector rows
select_item(item) ::= <%
<if(item.selected)>
<("> "); format="item-selector"><item.name; format="item-selector">
<({<figures.rightPointingQuotation> }); format="style-item-selector"><item.name; format="style-item-selector">
<else>
<(" ")><item.name>
<endif>
@@ -9,7 +9,7 @@ select_item(item) ::= <%
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
<({<figures.questionMark>}); format="style-list-value"> <model.name; format="style-title">
>>
// within info section, dedicated instructions for user
@@ -28,7 +28,7 @@ info(model) ::= <<
// component result
result(model) ::= <<
<question_name(model)> <model.value; format="value">
<question_name(model)> <model.value; format="style-value">
>>
// component is running

View File

@@ -5,7 +5,7 @@ info(model) ::= <%
<model.maskedInput>
<else>
<if(model.defaultValue)>
<("[Default "); format="value"><model.defaultValue; format="value"><("]"); format="value">
<("[Default "); format="style-value"><model.defaultValue; format="style-value"><("]"); format="style-value">
<endif>
<endif>
<else>
@@ -13,7 +13,7 @@ info(model) ::= <%
<model.input>
<else>
<if(model.defaultValue)>
<("[Default "); format="value"><model.defaultValue; format="value"><("]"); format="value">
<("[Default "); format="style-value"><model.defaultValue; format="style-value"><("]"); format="style-value">
<endif>
<endif>
<endif>
@@ -21,12 +21,12 @@ info(model) ::= <%
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
<({<figures.questionMark>}); format="style-list-value"> <model.name; format="style-title">
>>
// component result
result(model) ::= <<
<question_name(model)> <model.maskedResultValue; format="value">
<question_name(model)> <model.maskedResultValue; format="style-value">
>>
// component is running