Skip to content

Commit

Permalink
update org
Browse files Browse the repository at this point in the history
  • Loading branch information
jdongchen committed Dec 23, 2020
2 parents 9353778 + 3267139 commit 945646f
Show file tree
Hide file tree
Showing 10 changed files with 781 additions and 302 deletions.
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
<!--
* @Author: isJDongYa
* @LastEditors: isJDongYa
* @Date: 2020-12-07 19:31:31
* @LastEditTime: 2020-12-08 16:02:35
* @Description:
-->
# jd-moremsg
# jmoremsg

- 一个基于vue的“更多信息”的单个组件
- 根据包裹组件所在位置自动调整显示位置
Expand All @@ -14,9 +7,9 @@
## setup

```shell
npm install jd-moremsg --save
npm install @jdorg/jmoremsg --save

import JDMoremsg from 'jd-moremsg'
import JDMoremsg from '@jdorg/jmoremsg'

Vue.use(JDMoremsg)
```
Expand Down Expand Up @@ -55,11 +48,11 @@ interface Setup {

```ts
private defaultSetup:Setup = {
duration: 2000,
width: 'auto',
height: 'auto',
background: '#fff'
}
duration: 2000,
width: 'auto',
height: 'auto',
background: '#fff'
}
```

### follow
Expand Down Expand Up @@ -96,16 +89,29 @@ private defaultSetup:Setup = {
## example

```html
<jd-moremsg
<jmoremsg
text="This is more message"
:setup="{ background:'#ddd' }"
follow="follow"
>
<img class="img" slot="custom" src="./assets/imgs/header.jpg" alt="img">
<button class="btn">This is a button in default slot</button>
</jd-moremsg>
</jmoremsg>
```

```less
.btn {
height: 100px;
}
.img {
width: 300px;
}
```

![example](https://raw.githubusercontent.com/isJDongYa/jmoremsg/master/examples/assets/imgs/example.gif)

## 其它

@jdorg是一个开源前端组件的社区,如果你有开源组件的想法,欢迎加入我们

![qqqun](./examples/assets/imgs/@jdorg.jpg)
4 changes: 2 additions & 2 deletions examples/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div id="app">
<jd-moremsg
<jmoremsg
text="This is more message"
:setup="{
background:'#ddd'
Expand All @@ -9,7 +9,7 @@
>
<img class="img" slot="custom" src="./assets/imgs/header.jpg" alt="img">
<button class="btn">This is a button in default slot</button>
</jd-moremsg>
</jmoremsg>
</div>
</template>

Expand Down
Binary file added examples/assets/imgs/@jdorg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions examples/main.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
* @Author: isJDongYa
* @LastEditors: isJDongYa
* @Date: 2020-12-07 19:31:18
* @LastEditTime: 2020-12-08 12:58:26
* @Description:
*/
import Vue from 'vue'
import App from './App.vue'

import Lib from '../lib'
// import Lib from './jd-moremsg.umd.min.js'

// console.dir(Lib.MoreMsg.options.name);


Vue.use(Lib)
Expand Down
13 changes: 3 additions & 10 deletions lib/MoreMsg/MoreMsg.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<!--
* @Author: isJDongYa
* @LastEditors: isJDongYa
* @Date: 2020-12-07 16:32:14
* @LastEditTime: 2020-12-08 15:59:36
* @Description: 显示更多信息
-->
<template>
<div
class="more-msg"
Expand Down Expand Up @@ -33,11 +26,11 @@ import { Vue, Component, Prop } from 'vue-property-decorator'
import { Setup } from '@lib/types'
@Component
@Component({
name: 'MoreMsg'
})
export default class MoreMsg extends Vue {
static name = 'MoreMsg'

private winWidth:number = document.body.clientWidth;
private winHeigh:number = document.body.clientHeight;
private isShow:boolean = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/MoreMsg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MoreMsg from './MoreMsg.vue';

Object.assign(MoreMsg, {
install(Vue:VueConstructor){
Vue.component('jd-moremsg', MoreMsg);
Vue.component('jmoremsg', MoreMsg);
}
})

Expand Down
13 changes: 3 additions & 10 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/*
* @Author: isJDongYa
* @LastEditors: isJDongYa
* @Date: 2020-12-07 20:09:45
* @LastEditTime: 2020-12-08 11:51:47
* @Description:
*/
import { ComponentOptions, VueConstructor } from 'vue';
import MoreMsg from './MoreMsg';
import { ComponentOptions, VueConstructor } from 'vue'
import MoreMsg from './MoreMsg'

const components: {
[index:string]: VueConstructor
Expand All @@ -23,7 +16,7 @@ const install = (Vue:VueConstructor, options?:ComponentOptions<Vue>) => {
for (const key in components) {
if (components.hasOwnProperty(key)) {
const component = components[key];
Vue.component('jd-' + component.name.toLowerCase(), component)
Vue.component('j' + component.options.name.toLowerCase(), component)
}
}

Expand Down
11 changes: 11 additions & 0 deletions lib/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ export interface Setup {
width?:string;
height?:string;
background?:string;
}

import Vue from 'vue'

declare module 'vue/types/vue' {
// 声明为 Vue 补充的东西
interface VueConstructor {
options: {
name: string
}
}
}
Loading

0 comments on commit 945646f

Please sign in to comment.