-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui/form-details): add component form-details
- Loading branch information
Showing
6 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<template> | ||
<transition name="var-form-details"> | ||
<div class="var-form-details" v-if="errorMessage || maxlengthText"> | ||
<div class="var-form-details__message">{{ errorMessage }}</div> | ||
<div class="var-form-details__length">{{ maxlengthText }}</div> | ||
</div> | ||
</transition> | ||
</template> | ||
|
||
<script> | ||
import { props } from './props' | ||
import { defineComponent } from '../utils/create' | ||
export default defineComponent({ | ||
name: 'VarFormDetails', | ||
props, | ||
}) | ||
</script> | ||
|
||
<style lang="less"> | ||
@import '../styles/common'; | ||
@import './formDetails'; | ||
</style> |
7 changes: 7 additions & 0 deletions
7
packages/varlet-vue2-ui/src/form-details/__tests__/index.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Vue from 'vue' | ||
import FormDetails from '..' | ||
|
||
test('test form details plugin', () => { | ||
const app = Vue.use(FormDetails) | ||
expect(app.component(FormDetails.name)).toBeTruthy() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@form-details-error-color: var(--color-danger); | ||
@form-details-length-color: #888; | ||
@form-details-margin-top: 6px; | ||
@form-details-font-size: 12px; | ||
@form-details-message-margin-right: 4px; | ||
|
||
:root { | ||
--form-details-error-color: @form-details-error-color; | ||
--form-details-length-color: @form-details-length-color; | ||
--form-details-margin-top: @form-details-margin-top; | ||
--form-details-font-size: @form-details-font-size; | ||
--form-details-message-margin-right: @form-details-message-margin-right; | ||
} | ||
|
||
.var { | ||
&-form-details-enter-from, | ||
&-form-details-leave-to { | ||
opacity: 0; | ||
margin-top: 2px !important; | ||
} | ||
|
||
&-form-details-enter-active, | ||
&-form-details-leave-active { | ||
transition: 0.2s all var(--cubic-bezier); | ||
} | ||
} | ||
|
||
.var-form-details { | ||
display: flex; | ||
justify-content: space-between; | ||
font-size: var(--form-details-font-size); | ||
margin-top: var(--form-details-margin-top); | ||
|
||
&__message { | ||
flex-grow: 1; | ||
color: var(--form-details-error-color); | ||
margin-right: var(--form-details-message-margin-right); | ||
user-select: none; | ||
text-align: left; | ||
} | ||
|
||
&__length { | ||
flex-shrink: 0; | ||
color: var(--form-details-length-color); | ||
user-select: none; | ||
text-align: right; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { App } from 'vue' | ||
import FormDetails from './FormDetails.vue' | ||
|
||
FormDetails.install = function (app: App) { | ||
app.component(FormDetails.name, FormDetails) | ||
} | ||
|
||
export const _FormDetailsComponent = FormDetails | ||
|
||
export default FormDetails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const props = { | ||
errorMessage: { | ||
type: String, | ||
default: '', | ||
}, | ||
maxlengthText: { | ||
type: String, | ||
default: '', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters