Add options for hiding some elements (aka lyrics mode) #4

Merged
raoul merged 1 commits from no-chords into master 2021-09-08 05:25:04 +00:00
Showing only changes of commit 00e3a1fa4f - Show all commits

View File

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