-
-
Notifications
You must be signed in to change notification settings - Fork 180
Add Vocabulary Input implementation instead of buefy input #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
27f7b1e
a55e642
d59b9c1
dc669fd
4e50d6c
f3e4e71
e6ed75b
6c0ae8e
be2021b
2c6709d
1a73369
4358885
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><link rel="icon" href="/favicon.ico"><link rel="icon" type="image/png" href="https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png" sizes="192x192"><link rel="apple-touch-icon-precomposed" href="https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png"><meta name="twitter:card" content="summary"><meta name="twitter:site" content="@creativecommons"><meta name="twitter:creator" content="@creativecommons"><meta property="og:url" content="https://beta-chooser.creativecommons.org"><meta property="og:title" content="Choose a License"><meta property="og:type" content="website"><meta property="og:description" content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><meta property="og:image" content="https://mirrors.creativecommons.org/presskit/logos/cc.logo.large.png"><meta property="og:locale" content="en_US"><meta property="og:locale:alternate" content="ru_RU"><title>Choose a License</title><link href="/css/app.9b11c675.css" rel="preload" as="style"><link href="/js/app.a588ff01.js" rel="preload" as="script"><link href="/js/chunk-vendors.fa662221.js" rel="preload" as="script"><link href="/css/app.9b11c675.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but License Chooser doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.fa662221.js"></script><script src="/js/app.a588ff01.js"></script></body></html> | ||
| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><link rel="icon" href="/favicon.ico"><link rel="icon" type="image/png" href="https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png" sizes="192x192"><link rel="apple-touch-icon-precomposed" href="https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png"><meta name="twitter:card" content="summary"><meta name="twitter:site" content="@creativecommons"><meta name="twitter:creator" content="@creativecommons"><meta property="og:url" content="https://beta-chooser.creativecommons.org"><meta property="og:title" content="Choose a License"><meta property="og:type" content="website"><meta property="og:description" content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><meta property="og:image" content="https://mirrors.creativecommons.org/presskit/logos/cc.logo.large.png"><meta property="og:locale" content="en_US"><meta property="og:locale:alternate" content="ru_RU"><title>Choose a License</title><link href="/css/app.aac5d9bc.css" rel="preload" as="style"><link href="/js/app.8a1c7fdf.js" rel="preload" as="script"><link href="/js/chunk-vendors.f5ee90ab.js" rel="preload" as="script"><link href="/css/app.aac5d9bc.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but License Chooser doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.f5ee90ab.js"></script><script src="/js/app.8a1c7fdf.js"></script></body></html> |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,226 @@ | ||
| <template> | ||
| <div | ||
| :class="['control', sizeClass, { | ||
| 'has-icons-left': hasLeftIcon, | ||
| 'has-icons-right': hasRightIcon | ||
| }]" | ||
| > | ||
| <label :class="[sizeClass]"> | ||
| <span | ||
| v-if="label" | ||
| class="label" | ||
| >{{ label }} | ||
| <span | ||
| v-if="description" | ||
| class="description" | ||
| >{{ description }}</span> | ||
| </span> | ||
| <span :class="['control-inner', { 'disabled': isDisabled, 'readonly': isReadonly}]"> | ||
| <span | ||
| v-if="hasLeftIcon" | ||
| class="icon left-icon" | ||
| > | ||
| <slot name="left-icon" /> | ||
| </span> | ||
| <input | ||
| v-if="!isTextArea" | ||
| class="input" | ||
| :class="[sizeClass]" | ||
| :placeholder="placeholder" | ||
| :disabled="isDisabled" | ||
| :type="type" | ||
| :value="localValue" | ||
| @input="onInput" | ||
| > | ||
| <textarea | ||
| v-if="isTextArea" | ||
| class="textarea" | ||
| :value="localValue" | ||
| :placeholder="placeholder" | ||
| :disabled="isDisabled" | ||
| :readonly="isReadonly" | ||
| @input="onInput" | ||
| /> | ||
| <span | ||
| v-if="hasRightIcon" | ||
| class="icon right-icon" | ||
| > | ||
| <slot name="right-icon" /> | ||
| </span> | ||
| </span> | ||
| </label> | ||
| </div> | ||
| </template> | ||
| <script> | ||
| export default { | ||
| name: 'VInput', | ||
| props: { | ||
| value: { | ||
| type: String, | ||
| default: '' | ||
| }, | ||
| type: { | ||
| type: String, | ||
| default: 'text' | ||
| }, | ||
| label: { | ||
| type: String, | ||
| default: '' | ||
| }, | ||
| description: { | ||
| type: String, | ||
| default: '' | ||
| }, | ||
| placeholder: { | ||
| type: String, | ||
| default: '' | ||
| }, | ||
| isTextArea: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| isReadonly: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| isDisabled: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| size: { | ||
| type: String, | ||
| default: 'is-normal', | ||
| validate: function(value) { | ||
| return ['is-normal', 'is-medium', 'is-large'].indexOf(value) > -1 | ||
| } | ||
| } | ||
| }, | ||
| data() { | ||
| return { | ||
| localValue: this.value | ||
| } | ||
| }, | ||
| computed: { | ||
| computedValue: { | ||
| get() { | ||
| return this.localValue | ||
| }, | ||
| set(newVal) { | ||
| this.localValue = newVal | ||
| this.$emit('input', newVal) | ||
| } | ||
| }, | ||
| sizeClass() { | ||
| return this.size === 'normal' ? '' : this.size | ||
| }, | ||
| hasLeftIcon() { | ||
| // Check if the 'left-icon' slot has content, return a boolean value | ||
| return !!this.$slots['left-icon'] | ||
| }, | ||
| hasRightIcon() { | ||
| // Check if the 'right-icon' slot has content, return a boolean value | ||
| return !!this.$slots['right-icon'] | ||
| } | ||
| }, | ||
| methods: { | ||
| onInput(event) { | ||
| this.localValue = event.target.value | ||
| this.computedValue = event.target.value | ||
| } | ||
| } | ||
| } | ||
| // <!--'', is-medium, is-large in vocabulary; normal, big, huge in DL--> | ||
|
|
||
| </script> | ||
|
|
||
| <style lang="scss" scoped > | ||
| @import "~@creativecommons/vocabulary/scss/color.scss"; | ||
| @import "~@creativecommons/vocabulary/scss/typography.scss"; | ||
| .input, .textarea { | ||
| border: none; | ||
| &:hover, &:active, &:focus { | ||
| border-color: $color-gray; | ||
| } | ||
| } | ||
|
|
||
| label { | ||
| &.is-medium { | ||
| .label, .description { | ||
| font-size: $font-size-body-bigger; | ||
| } | ||
| } | ||
| } | ||
| .label, .description { | ||
| display: block; | ||
| margin-bottom: 0.5rem; | ||
| } | ||
| .label { | ||
| font-weight: bold; | ||
| } | ||
| .description { | ||
| font-weight: normal; | ||
| } | ||
| .control { | ||
| .control-inner { | ||
| border: 0.125rem solid $color-light-gray; | ||
| border-radius: 4px; | ||
| background-color: white; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| &:hover:not(.disabled):not(.readonly), | ||
| &:active:not(.disabled):not(.readonly), | ||
| &:focus:not(.disabled):not(.readonly) { | ||
| border-color: $color-gray; | ||
| .icon { | ||
| color: $color-gray; | ||
| } | ||
| } | ||
| &.disabled { | ||
| background-color: $color-lighter-gray; | ||
| textarea { | ||
| background-color: $color-lighter-gray; | ||
| } | ||
| } | ||
| } | ||
| .input { | ||
| width: 100%; | ||
| padding-left: 1rem; | ||
| padding-right: 1rem; | ||
| border-color: transparent; | ||
| margin-top: 0; | ||
| } | ||
|
|
||
| .icon { | ||
| position: static; | ||
| height: 1.25rem; | ||
| width: 1.25rem; | ||
| &.left-icon { | ||
| margin-left: 1rem; | ||
| } | ||
| &.right-icon { | ||
| margin-right: 1rem; | ||
| } | ||
| .icon-img { | ||
| height: auto; | ||
| width: 100%; | ||
| pointer-events: none; | ||
| cursor: unset; | ||
| &.clickable { | ||
| pointer-events: auto; | ||
| cursor: pointer; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
| .control.is-large { | ||
| .left-icon { | ||
| margin-left: 1.5rem; | ||
| } | ||
| .right-icon { | ||
| margin-right: 1.5rem; | ||
| } | ||
| } | ||
| </style> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
inheritAttrs: falseand then place the$attrson the input. See docs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for a late reply, @dhruvkb ! I was writing this component as a more general Input component for Vocabulary that can be a text input or a text area. The solution you propose is really clean, but for a simpler component.
Some of these props, such as
description,label,valueare necessary for the component itself, and some could be bound to theinputor thetextarea, so I thought leaving them as props would be better.