项目作者: iota-cn

项目描述 :
A suite of Vue components to show avatar, crop avatar, get avatar's content for upload.
高级语言: Vue
项目地址: git://github.com/iota-cn/vue-iota-avatar.git
创建时间: 2019-10-21T05:57:48Z
项目社区:https://github.com/iota-cn/vue-iota-avatar

开源协议:MIT License

下载


@iota-cn/avatar

Install

  1. npm install @iota-cn/avatar

Use

Import

  1. import Avatar from '@iota-cn/avatar'
  2. import '@iota-cn/avatar/dist/avatar.css'
  3. Vue.use(Avatar)

AvatarViewer

  1. <template>
  2. <div id="examples">
  3. <div class='section'>
  4. <h3>AvatarViewer</h3>
  5. <code>
  6. </code>
  7. <h4>Example</h4>
  8. <div class='example'>
  9. <iota-avatar-viewer showUpload
  10. nickname="Hi"
  11. :img="vueImg"
  12. :radius='51' ></iota-avatar-viewer>
  13. </div>
  14. </div>
  15. </div>
  16. </template>

Props

  1. props: {
  2. showUpload: Boolean, // Whether show upload icon
  3. nickname: { // the name show when image is missing
  4. type: String
  5. },
  6. img: String, // avatar image
  7. width: {
  8. type: Number,
  9. default: 100
  10. },
  11. height: {
  12. type: Number,
  13. default: 100
  14. },
  15. radius: {
  16. type: Number,
  17. default: 4
  18. },
  19. color: { // background color
  20. type: String,
  21. default: 'gray'
  22. },
  23. userStyle: { // custome styles
  24. type: Object,
  25. default() {
  26. return undefined
  27. }
  28. }
  29. }

RawAvatar

  1. <template>
  2. <div id="examples">
  3. <div class='section'>
  4. <h3>RawAvatar</h3>
  5. <code>
  6. </code>
  7. <h4>Example</h4>
  8. <div class='example'>
  9. <iota-rawavatar :img='vueImg'></iota-rawavatar>
  10. </div>
  11. </div>
  12. </div>
  13. </template>

Props

  1. props: {
  2. uploadImg: Function, // call back to handle image changed(click then select a new image)
  3. width: Number,
  4. height: Number,
  5. img: String, // image to show, you can reset it after the 'uploadImg' handler finished.
  6. tips: Array, // tips show to the user.
  7. disabled: Boolean, // disable click event
  8. }

AvatarEditor

  1. <template>
  2. <div id="examples">
  3. <div class='section'>
  4. <h3>AvatarEditor</h3>
  5. <code>
  6. </code>
  7. <h4>Example</h4>
  8. <div class='example'>
  9. <div class="example-avatar-editor">
  10. <iota-avatar-editor :avatarFile='vueImg' ></iota-avatar-editor>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. </template>

Props

  1. props: {
  2. title: { // Editor title, default: Upload Image
  3. type: String
  4. },
  5. previewHint: { // hint of preview, default: Preview
  6. type: String
  7. },
  8. selectImgHint: { // hint of select image, default: Select Image
  9. type: String
  10. },
  11. cropHint: { // hint of crop, default: Best size 'width'x'height', you can cut it.
  12. type: String
  13. },
  14. onAvatarData: Function, // call back to process the image content.
  15. radiusPerc: Number, // radius percent, default: 100 (%)
  16. width: Number, // width of cut window, default: 100 (px)
  17. height: Number, // height of cut window, default: 100 (px)
  18. avatarFile: { // the image to show
  19. type: [Object, String, File]
  20. }
  21. }

Avatar

  1. <template>
  2. <div id="examples">
  3. <div class='section'>
  4. <h3>AvatarEditor with default Modal</h3>
  5. <code>
  6. </code>
  7. <h4>Example</h4>
  8. <div class='example'>
  9. <iota-avatar ></iota-avatar>
  10. </div>
  11. </div>
  12. </div>
  13. </template>

Props

  1. props: {
  2. title: String, // Editor title, default: Upload Image
  3. previewHint: String, // hint of preview, default: Preview
  4. selectImgHint: String, // hint of select image, default: Select Image
  5. cropHint: String, // hint of crop, default: Best size 'width'x'height', you can cut it.
  6. onAvatarData: Function, // call back to process the image content.
  7. width: Number, // width of cut window, default: 100 (px)
  8. height: Number, // height of cut window, default: 100 (px)
  9. radiusPerc: Number // radius percent, default: 100 (%)
  10. }

slot

  1. controller // replace default 'Select Image' button, for example, you can use an AvataViewer inside the Avatar
  2. head // replace the "default header" in opened modal dialog.

Example

  1. git clone git@github.com:iota-cn/vue-iota-avatar.git
  2. cd vue-iota-avatar
  3. npm i
  4. npm run examples
  1. DONE Compiled successfully in 9558ms 13:15:45
  2. App running at:
  3. - Local: http://localhost:8080/
  4. ...