From b45574b83da655d9b5e48d5ef5ce7f2e147e3bbf Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 12 Feb 2022 12:13:52 +0100 Subject: Text field update --- tpl/index.pug | 39 ++++++++++++++++++--------------------- tpl/objects/text-field.pug | 29 ++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 26 deletions(-) (limited to 'tpl') diff --git a/tpl/index.pug b/tpl/index.pug index a6a8f87..365ca52 100644 --- a/tpl/index.pug +++ b/tpl/index.pug @@ -112,28 +112,25 @@ html +rule('medium') +box - +text-field(placeholder='Placeholder') - br - br - +text-field(value='Just landed in L.A.') - br - br - +text-field(value='Readonly' readonly=true) - br - br - +text-field(value='Incorrect input' pattern='a+' required=true) - br - br - +text-field(placeholder='Placeholder' disabled=true) - br - br - +text-field(value='Just landed in L.A.' disabled=true) - br - br - +text-field(value='Readonly' readonly=true disabled=true) - br + div(style={ display: 'flex', gap: '1rem' }) + +text-field(placeholder='Placeholder') + +text-field(value='Just landed in L.A.') + +text-field(value='Readonly' readonly=true) + +text-field(value='Incorrect input' pattern='a+' required=true) br - +text-field(value='Incorrect input' pattern='a+' required=true disabled=true) + div(style={ display: 'flex', gap: '1rem' }) + +text-field(placeholder='Placeholder' disabled=true) + +text-field(value='Just landed in L.A.' disabled=true) + +text-field(value='Readonly' readonly=true disabled=true) + +text-field(value='Incorrect input' pattern='a+' required=true disabled=true) + br + div + +text-field(placeholder='Just landed in L.A.') + +slot('pre') + +action-button(quiet=true selected=true class='l-card__block')= 'Volpeon' + +slot('post') + +action-button(quiet=true icon='smile' class='l-card__block') + +action-button(quiet=true icon='send' class='l-card__block') //----------------------------------------- diff --git a/tpl/objects/text-field.pug b/tpl/objects/text-field.pug index c933b69..24f8e21 100644 --- a/tpl/objects/text-field.pug +++ b/tpl/objects/text-field.pug @@ -1,13 +1,32 @@ include icon.pug mixin text-field + - const slots = {} + + mixin slot(key) + - slots[key] = block + - + block ? block() : undefined + let classes = { - 'o-text-field': true, - 'is-invalid': attributes.invalid, - 'is-disabled': attributes.disabled, + 'o-text-field': true, + 'o-text-field--ext': attributes.ext, + 'is-invalid': attributes.invalid, + 'is-disabled': attributes.disabled, + 'l-card': !!block, + 'l-card--flush': !!block, + 'l-card--gapless': !!block } div(class=classes aria-disabled=attributes.disabled && String(attributes.disabled)) - input(class='o-text-field__native')&attributes(attributes) - .o-text-field__bg + if !!block + if slots.pre + - slots.pre() + input.o-text-field__native.l-card__block.l-card__block--main&attributes(attributes) + if slots.post + - slots.post() + .o-text-field__bg + else + input.o-text-field__native&attributes(attributes) + .o-text-field__bg -- cgit v1.2.3-70-g09d2