Add config_display option to support regular and large renders (#310)

This commit is contained in:
Simon Lecoq
2021-05-18 22:31:53 +02:00
committed by GitHub
parent 04bf1f0316
commit ed0da41973
36 changed files with 586 additions and 402 deletions

View File

@@ -140,6 +140,21 @@ It may increase filesize since it replace unicode characters by SVG images.
config_twemoji: yes
```
### ↔️ Controlling display size
Some templates like `classic` and `repositories` support different output display size:
- `regular` (default) will render a medium-sized image, which is suitable for both desktop and mobile displays and is preferable when using data-intensive metrics (since text may be scaled down on small devices)
- `large` will render a large-sized image, which may be more suitable for some plugins (like displaying topics icons, repository contributors, etc.)
#### Examples workflows
```yaml
- uses: lowlighter/metrics@latest
with:
# ... other options
config_display: large
```
### 🎞️ SVG CSS Animations
As rendered metrics use HTML and CSS, some templates have animations.

View File

@@ -6,7 +6,7 @@
//Setup
export default async function({login, q}, {conf, data, rest, graphql, plugins, queries, account, convert, template}, {pending, imports}) {
//Load inputs
const {"config.animations":animations, "config.timezone":_timezone, "debug.flags":dflags} = imports.metadata.plugins.core.inputs({data, account, q})
const {"config.animations":animations, "config.display":display, "config.timezone":_timezone, "debug.flags":dflags} = imports.metadata.plugins.core.inputs({data, account, q})
imports.metadata.templates[template].check({q, account, format:convert})
//Init
@@ -29,6 +29,9 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
}
}
//Display
data.large = display === "large"
//Animations
data.animated = animations
console.debug(`metrics/compute/${login} > animations ${data.animated ? "enabled" : "disabled"}`)

View File

@@ -167,6 +167,15 @@ inputs:
type: boolean
default: yes
# Render display width
config_display:
description: Render display width
type: string
default: regular
values:
- regular # 480px width
- large # 960px width (may not be supported by all templates)
# Enable SVG CSS animations
config_animations:
description: SVG CSS animations