Skip to content

Commit

Permalink
chore: update the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangmo8 committed Apr 14, 2023
1 parent beb6095 commit f643334
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 55 deletions.
41 changes: 5 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
<!--
Get your module up and running quickly.
Find and replace all on all files (CMD+SHIFT+F):
- Name: Varlet Module
- Package name: Varlet Module
- Description: Varlet Module
-->

# Varlet Nuxt (WIP)
# Varlet Nuxt

Welcome to contribute this repo

<!-- [![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href] -->

Varlet Module for Nuxt3

<!-- - [✨ &nbsp;Release Notes](/CHANGELOG.md) -->
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
<!-- - [📖 &nbsp;Documentation](https://example.com) -->

## Features

<!-- Highlight some of the features your module provide here -->
- Automatically import directives.
- Automatically import of showDialog, showToast and other methods components.
- Make up the Lazy Option
- Component Demo for Playground
- Template for Nuxt3


## Quick Setup
Expand Down Expand Up @@ -57,7 +39,7 @@ export default defineNuxtConfig({
})
```

That's it! You can now use My Module in your Nuxt app ✨
That's it! You can now use Varlet Module in your Nuxt app ✨

## Development

Expand All @@ -84,16 +66,3 @@ npm run test:watch
# Release new version
npm run release
```

<!-- Badges -->
<!-- [npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/my-module
[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/my-module
[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/my-module
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
[nuxt-href]: https://nuxt.com -->
24 changes: 15 additions & 9 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ const show = ref(false)
</script>

<template>
<var-button type="primary" block @click="show = !show">基本使用</var-button>
<var-snackbar v-model:show="show">
这是一个消息条!!
</var-snackbar>
<div v-ripple class="ripple-example-block">点击</div>
<var-skeleton :loading="show">
加载的数据
</var-skeleton>
<div>
<var-button type="primary" block @click="show = !show">
基本使用
</var-button>
<var-snackbar v-model:show="show">
这是一个消息条!!
</var-snackbar>
<div v-ripple class="ripple-example-block">
点击
</div>
<var-skeleton :loading="show">
加载的数据
</var-skeleton>
</div>
</template>

<style>
Expand All @@ -32,4 +38,4 @@ const show = ref(false)
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
transition: background-color 0.25s;
}
</style>
</style>
4 changes: 2 additions & 2 deletions src/core/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { kebabCase } from '@varlet/shared'
import { moduleName, functionComponents } from '../config'
import { ModuleOptions } from '../types'

export function resolveComponents(config: ModuleOptions) {
export function resolveComponents (config: ModuleOptions) {
const { components } = config

components.forEach((item) => {
Expand All @@ -23,7 +23,7 @@ export function resolveComponents(config: ModuleOptions) {
})
}

export function resolveStyles(config: ModuleOptions, name: string) {
export function resolveStyles (config: ModuleOptions, name: string) {
const { components } = config

if (functionComponents.includes(name)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { kebabCase } from '@varlet/shared'
import { moduleName } from '../config'
import type { ModuleOptions } from '../types'

export function resolveDirectives(
export function resolveDirectives (
config: ModuleOptions,
name: string
): undefined | [name: string, styles?: string] {
Expand Down
2 changes: 1 addition & 1 deletion src/core/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { addImportsSources } from '@nuxt/kit'
import { moduleName } from '../config'
import type { ModuleOptions } from '../types'

export function resolveImports(config: ModuleOptions) {
export function resolveImports (config: ModuleOptions) {
const { imports } = config

addImportsSources({
Expand Down
2 changes: 1 addition & 1 deletion src/core/options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNuxt } from '@nuxt/kit'
import { moduleName } from '../config'

export function resolveOptions() {
export function resolveOptions () {
const nuxt = useNuxt()

nuxt.options.build.transpile.push(moduleName)
Expand Down
4 changes: 2 additions & 2 deletions src/core/transformPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export const transformPlugin = createUnplugin((options: PluginOptions) => {
return {
name: `${moduleName}:transform`,
enforce: 'post',
transformInclude(id) {
transformInclude (id) {
if (exclude.some(pattern => id.match(pattern))) {
return false
}
if (include.some(pattern => id.match(pattern))) {
return true
}
},
transform(code, id) {
transform (code, id) {
const imports = new Set<string>()
const directives: PresetImport[] = []
const s = new MagicString(code)
Expand Down
4 changes: 2 additions & 2 deletions src/gen.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { moduleName } from './config'
import { PresetImport } from './types'

export function genSideEffectsImport(value: string): string {
export function genSideEffectsImport (value: string): string {
return `import '${value}';`
}

export function genLibraryImport(list: PresetImport[]): string {
export function genLibraryImport (list: PresetImport[]): string {
const values = list.map((item) => {
if (Array.isArray(item)) {
const [name, as] = item
Expand Down
2 changes: 1 addition & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineNuxtModule<ModuleOptions>({
configKey: moduleName
},
defaults,
setup(_options: ModuleOptions, nuxt) {
setup (_options: ModuleOptions, nuxt) {
const _configs = _options
resolveOptions()

Expand Down

0 comments on commit f643334

Please sign in to comment.