Add options for hiding some elements (aka lyrics mode)

This commit is contained in:
Raoul Snyman 2021-09-07 22:16:04 -07:00
parent 2bcfdaf0de
commit 00e3a1fa4f
Signed by: raoul
GPG Key ID: F55BCED79626AE9C
1 changed files with 39 additions and 5 deletions

View File

@ -46,6 +46,7 @@ STYLE_KEYS = [
'is_bold',
'is_centered',
'is_upper',
'is_hidden',
'indent'
]
HTML_OPTIONS = {
@ -223,6 +224,12 @@ HTML_OPTIONS = {
'default': True,
'group': 'stanza_heading'
},
'stanza_heading_is_hidden': {
'description': 'Hide the stanza headings',
'type': bool,
'default': False,
'group': 'stanza_heading'
},
'verse_font': {
'description': 'The font for the verses',
'type': str,
@ -271,6 +278,12 @@ HTML_OPTIONS = {
'default': True,
'group': 'verse_heading'
},
'verse_heading_is_hidden': {
'description': 'Hide the verse headings',
'type': bool,
'default': False,
'group': 'verse_heading'
},
'chorus_font': {
'description': 'The font for the choruses',
'type': str,
@ -319,6 +332,12 @@ HTML_OPTIONS = {
'default': True,
'group': 'chorus_heading'
},
'chorus_heading_is_hidden': {
'description': 'Hide the chorus headings',
'type': bool,
'default': False,
'group': 'chorus_heading'
},
'bridge_font': {
'description': 'The font for the bridge',
'type': str,
@ -367,6 +386,12 @@ HTML_OPTIONS = {
'default': True,
'group': 'bridge_heading'
},
'bridge_heading_is_hidden': {
'description': 'Hide the bridge headings',
'type': bool,
'default': False,
'group': 'bridge_heading'
},
'chord_font': {
'description': 'The font for the chord',
'type': str,
@ -390,7 +415,13 @@ HTML_OPTIONS = {
'type': bool,
'default': True,
'group': 'chord'
}
},
'chord_is_hidden': {
'description': 'Hide all the chords',
'type': bool,
'default': False,
'group': 'chord'
},
}
_OPTION_GROUPS = []
@ -411,7 +442,7 @@ def get_option_groups():
return _OPTION_GROUPS
def make_style(name, font=None, size=None, is_bold=None, is_centered=None, is_upper=None, indent=None):
def make_style(name, font=None, size=None, is_bold=None, is_centered=None, is_upper=None, is_hidden=False, indent=None):
"""Build a CSS style"""
styles = []
if name == 'default':
@ -428,6 +459,9 @@ def make_style(name, font=None, size=None, is_bold=None, is_centered=None, is_up
styles.append(' text-align: center;')
if is_upper:
styles.append(' text-transform: uppercase;')
if is_hidden:
styles.append(' display: none !important;')
styles.append(' visibility: hidden !important;')
if indent:
styles.append(' margin-left: {indent}rem;'.format(indent=indent))
if styles:
@ -447,9 +481,9 @@ def generate_option_styles(options):
name = '{group}_{key}'.format(group=group, key=key)
if name not in HTML_OPTIONS:
continue
option = options.get(name, HTML_OPTIONS[name]['default'])
if option:
kwargs[key] = option
value = options.get(name, HTML_OPTIONS[name]['default'])
if value is not None:
kwargs[key] = value
styles.append(make_style(group.replace('_', '-'), **kwargs))
return styles