forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03c8b7f
commit c88da36
Showing
66 changed files
with
2,716 additions
and
17 deletions.
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
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,39 @@ | ||
const package = require('../package.json'); | ||
const config = require('../src/config.json'); | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
let importStr = `import { App } from 'vue';\n`; | ||
const packages = []; | ||
config.nav.map(item => { | ||
item.packages.forEach(element => { | ||
let { name, show, type, taro } = element; | ||
if (show && taro) { | ||
importStr += `import ${name} from './__VUE/${name.toLowerCase()}/index${ | ||
type === 'methods' ? '' : '.taro.vue' | ||
}';\n`; | ||
packages.push(name); | ||
} | ||
}); | ||
}); | ||
let installFunction = `function install(app: App) { | ||
const packages = [${packages.join(',')}]; | ||
packages.forEach((item:any) => { | ||
if (item.install) { | ||
app.use(item); | ||
} else if (item.name) { | ||
app.component(item.name, item); | ||
} | ||
}); | ||
}`; | ||
let fileStr = `${importStr} | ||
${installFunction} | ||
export { ${packages.join(',')} }; | ||
export default { install, version:'${package.version}'};`; | ||
fs.outputFile( | ||
path.resolve(__dirname, '../src/packages/nutui.taro.vue.ts'), | ||
fileStr, | ||
'utf8', | ||
error => { | ||
// logger.success(`${package_config_path} 文件写入成功`); | ||
} | ||
); |
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
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
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
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,125 @@ | ||
<template> | ||
<view :class="classes" :style="getStyle" @click="handleClick"> | ||
<view class="nut-button__warp"> | ||
<nut-icon class="nut-icon-loading" v-if="loading"></nut-icon> | ||
<nut-icon :class="icon" v-if="icon && !loading" :name="icon"></nut-icon> | ||
<view :class="{ text: icon || loading }" v-if="$slots.default"> | ||
<slot></slot> | ||
</view> | ||
</view> | ||
</view> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { PropType, CSSProperties, toRefs, computed } from 'vue'; | ||
import { createComponent } from '../../utils/create'; | ||
const { componentName, create } = createComponent('button'); | ||
export type ButtonType = | ||
| 'default' | ||
| 'primary' | ||
| 'info' | ||
| 'success' | ||
| 'warning' | ||
| 'danger'; | ||
export type ButtonSize = 'large' | 'normal' | 'small'; | ||
export type ButtonShape = 'square' | 'round'; | ||
export default create({ | ||
props: { | ||
color: String, | ||
shape: { | ||
type: String as PropType<ButtonShape>, | ||
default: 'round' | ||
}, | ||
plain: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
loading: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
type: { | ||
type: String as PropType<ButtonType>, | ||
default: 'default' | ||
}, | ||
size: { | ||
type: String as PropType<ButtonSize>, | ||
default: 'normal' | ||
}, | ||
block: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
icon: { | ||
type: String, | ||
default: '' | ||
} | ||
}, | ||
emits: ['click'], | ||
setup(props, { emit, slots }) { | ||
const { | ||
type, | ||
size, | ||
shape, | ||
disabled, | ||
loading, | ||
color, | ||
plain, | ||
block | ||
} = toRefs(props); | ||
const handleClick = (event: MouseEvent) => { | ||
if (!loading.value && !disabled.value) { | ||
emit('click', event); | ||
} | ||
}; | ||
const classes = computed(() => { | ||
const prefixCls = componentName; | ||
return { | ||
[prefixCls]: true, | ||
[`${prefixCls}--${type.value}`]: type.value, | ||
[`${prefixCls}--${size.value}`]: size.value, | ||
[`${prefixCls}--${shape.value}`]: shape.value, | ||
[`${prefixCls}--plain`]: plain.value, | ||
[`${prefixCls}--block`]: block.value, | ||
[`${prefixCls}--disabled`]: disabled.value, | ||
[`${prefixCls}--loading`]: loading.value | ||
}; | ||
}); | ||
const getStyle = computed(() => { | ||
const style: CSSProperties = {}; | ||
if (color?.value) { | ||
if (plain.value) { | ||
style.color = color.value; | ||
style.background = '#fff'; | ||
if (!color.value?.includes('gradient')) { | ||
style.borderColor = color.value; | ||
} | ||
} else { | ||
style.color = '#fff'; | ||
style.background = color.value; | ||
} | ||
} | ||
return style; | ||
}); | ||
return { | ||
handleClick, | ||
classes, | ||
getStyle | ||
}; | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import 'index.scss'; | ||
</style> |
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
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,93 @@ | ||
<template> | ||
<view :class="classes" @click="handleClick"> | ||
<slot> | ||
<view | ||
class="nut-cell__title" | ||
:class="{ icon: icon }" | ||
v-if="title || subTitle || icon" | ||
> | ||
<nut-icon v-if="icon" class="icon" :name="icon"></nut-icon> | ||
<template v-if="subTitle"> | ||
<view class="title">{{ title }}</view> | ||
<view class="nut-cell__title-desc">{{ subTitle }}</view> | ||
</template> | ||
<template v-else> | ||
{{ title }} | ||
</template> | ||
</view> | ||
<view | ||
v-if="desc" | ||
class="nut-cell__value" | ||
:style="{ 'text-align': descTextAlign }" | ||
>{{ desc }}</view | ||
> | ||
|
||
<slot v-if="$slots.link" name="link"></slot> | ||
<nut-icon | ||
v-else-if="isLink || to" | ||
class="nut-cell__link" | ||
name="right" | ||
></nut-icon> | ||
</slot> | ||
</view> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed } from 'vue'; | ||
import { createComponent } from '../../utils/create'; | ||
import { useRouter } from 'vue-router'; | ||
import CellGroup from '../cellgroup/index.vue'; | ||
const { componentName, create } = createComponent('cell'); | ||
export default create({ | ||
props: { | ||
title: { type: String, default: '' }, | ||
subTitle: { type: String, default: '' }, | ||
desc: { type: String, default: '' }, | ||
descTextAlign: { type: String, default: 'right' }, | ||
isLink: { type: Boolean, default: false }, | ||
to: { type: String, default: '' }, | ||
replace: { type: Boolean, default: false }, | ||
url: { type: String, default: '' }, | ||
icon: { type: String, default: '' } | ||
}, | ||
emits: ['click'], | ||
components: { | ||
[CellGroup.name]: CellGroup | ||
}, | ||
setup(props, { emit }) { | ||
const classes = computed(() => { | ||
const prefixCls = componentName; | ||
return { | ||
[prefixCls]: true, | ||
[`${prefixCls}--clickable`]: props.isLink || props.to | ||
}; | ||
}); | ||
const router = useRouter(); | ||
const handleClick = (event: Event) => { | ||
emit('click', event); | ||
if (props.to && router) { | ||
router[props.replace ? 'replace' : 'push'](props.to); | ||
// if(props.replace){ | ||
// router.replace(props.to) | ||
// }else{ | ||
// router.push(props.to) | ||
// } | ||
} else if (props.url) { | ||
props.replace | ||
? location.replace(props.url) | ||
: (location.href = props.url); | ||
} | ||
}; | ||
return { | ||
handleClick, | ||
classes | ||
}; | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import 'index.scss'; | ||
</style> |
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
Oops, something went wrong.