• Stars
    star
    186
  • Rank 206,532 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🗃️Smart widget is a flexible and extensible content container component for Vue2.x / Vue3.x in Next branch.

vue-smart-widget

Smart widget is a flexible and extensible content container component. It includes header and body part, and widget body includes editboxcontentfooter. If you use with grid, it also have a draggable and resizable grid layout, base on Vue2.5.+ & vue-grid-layout.

Both Support Vue 2/Vue 3

Vue 2 | Vue 3

Installation

Vue 2

npm i vue-smart-widget -S

Vue 3

npm i vue-smart-widget@next -S

Import

Install all the components:

import Vue from 'vue'
import VueSmartWidget from 'vue-smart-widget'

Vue.use(VueSmartWidget)

Use widget only:

import Vue from 'vue'
import { SmartWidget } from 'vue-smart-widget'

Vue.component('SmartWidget', SmartWidget)

Usage

The SmartWidget is heavily base on vue-grid-layout, you can know about vue-grid-layout first, maybe you already use in your project.

Use widget only

Html

<smart-widget title="Default Widget">
  <p>
    It's default widget.
  </p>
</smart-widget>

Use widget with grid

import Vue from 'vue'
import { SmartWidgetGrid } from 'vue-smart-widget'

Vue.component('SmartWidgetGrid', SmartWidgetGrid)

Script

new Vue({
  data () {
    return {
      layout: [
        { x: 0, y: 0, w: 4, h: 4, i: '0' },
        { x: 4, y: 0, w: 4, h: 4, i: '1' },
        { x: 8, y: 0, w: 4, h: 4, i: '2' }
      ]
    }
  }
})

Html

<smart-widget-grid :layout="layout">
  <smart-widget slot="0" simple>
    <div class="layout-center">
      <h3>Simple Widget Without Header</h3>
    </div>
  </smart-widget>
  <smart-widget slot="1" title="Default Widget">
    <div class="layout-center">
      <h3>Default Widget With Header</h3>
    </div>
  </smart-widget>
  <smart-widget slot="2" title="Full Screen" fullscreen>
    <div class="layout-center">
      <h3>Make any widget full screen</h3>
    </div>
  </smart-widget>
</smart-widget-grid>

SmartWidget Props

Attribute Description Type Accepted values Default
slot Widget slot, the unique identifier of the widget. refer to SmartWidgetGrid Props String - -
title Widget Header Title String - -
subTitle Widget Header Sub Title String - -
padding padding in Widget Body [Number, Array] - [12, 20]
simple Widget without Header Boolean true or false false
loading determine whether it's loading Boolean true or false false
fullscreen determine whether have fullscreen button Boolean true or false false
collapse determine whether have collapse button, only support smart-widget Boolean true or false false
refresh determine whether have refresh button Boolean true or false false
fixedHeight determine whether widget body's height is fixed, only support smart-widget Boolean true or false false
shadow when to show card shadows String alwayshovernever always
translateY the length of vertically transform Number - 0
isActived determine whether widget is actived Boolean true or false false
activedColor the actived widget box-shadow color, usually used with isActived attribute String hex color #0076db
headerHeight Widget Header Height(px) Number - 48

SmartWidget Methods

Name Description Parameters
move Every time an item is being moved and changes position (i, newX, newY)
moved Every time an item is finished being moved and changes position (i, newX, newY)
resize Every time an item is being resized and changes size (i, newH, newW, newHPx, newWPx)
resized Every time an item is finished being moved and changes position (i, newH, newW, newHPx, newWPx)
container-resized Every time the grid item/layout container changes size (browser window or other) (i, newH, newW, newHPx, newWPx)
on-refresh Used when the widget need fetching data from ajax methods, usually used with loading attribute -
before-fullscreen Used when the widget before fullscreen, usually used with fullscreen attribute true or false
on-fullscreen Used when the widget is already fullscreen, usually used with fullscreen attribute true or false

CSS Selector in SmartWidget

Name Description
.smartwidget The main selector in SmartWidget
.is-actived The state of widget is actived
.vue-grid-item.vue-grid-placeholder The default css for the placeholder

SmartWidgetGrid Props

It's similar with vue-grid-layout. Care about the attribute layout, The value of layout must be an Array of Object items. Each item must have i, x, y, w and h proprties. especially, the i proprties, it's the unique identifier of the widget item, euqal with widget slot.

Attribute Description Type Accepted values Default
layout This is the initial layout of the grid. Array - required
responsiveLayouts This is the initial layouts of the grid per breakpoint if responsive is set to true. Object - {}
colNum Says how many columns the grid has. Number - 12
rowHeight Says what is a height of a single row in pixels. Number - 48
maxRows Says what is a maximal number of rows in the grid. Number - Infinity
margin Says what are the margins of elements inside the grid. Array - [10, 10]
draggable Says if the grids items are draggable. Boolean true or false true
resizable Says if the grids items are resizable. Boolean true or false true
isMirrored Says if the RTL/LTR should be reversed. Boolean true or false false
autoSize Says if the container height should swells and contracts to fit contents. Boolean true or false true
verticalCompact Says if the layout should be compact vertically. Boolean true or false true
preventCollision Says if grid items will move when being dragged over. Boolean true or false false
responsive Says if the layout should be responsive to window width. Boolean true or false false
breakpoints Breakpoints defined for responsive layout. Sets widths on wich column number changes. Object - { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }
cols Defines number of columns for each breakpoint. Object - { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }
isStatic Control all widgets won't be draggable, resizable or moved Boolean true or false false

Slot scopes

Each widget in the grid is resizable, slot-scope provide the widget attribute to the children component.

Name Description Type
contentH Provide the widget body content(widget-body__content) height Number

SmartWidgetGrid Methods

Name Description Parameters
layout-created Emited on the component created lifecycle hook newLayout
layout-before-mount Emited on the component beforeMount lifecycle hook newLayout
layout-mounted Emited on the component mounted lifecycle hook newLayout
layout-ready Emited when all the operations on the mount hook finish newLayout
layout-updated Every time the layout has finished updating and positions of all grid-items are recalculated newLayout
breakpoint-changed Every time the breakpoint value changes due to window resize (newBreakpoint, newLayout)

License

MIT @xiaoluoboding

More Repositories

1

vue-sonner

🔔 An opinionated toast component for Vue.
Vue
763
star
2

vue-command-palette

⌨️ A fast, composable, unstyled command palette interface for Vue.
Vue
519
star
3

bookmark.style

🪄 Turn any link into a stylish visual web bookmark, one-click to copy the beautiful web bookmark image.
Vue
310
star
4

ghost-theme-kaldorei

🎨 A Simple And Elegant Ghost Theme Derive From Default Theme Casper
CSS
291
star
5

vue-demo-collection

A collection of Vue.js demos
Vue
268
star
6

vue-stroll

📜 Vue.js + Stroll.js. Awesome CSS list scroll effects for Vue2.x.
Vue
157
star
7

chrome-ext-starter

⚡️ Modernized Chrome Extension Manifest V3 Vite Starter Template
TypeScript
140
star
8

xiaoluoboding

My GitHub Profile. Before Fork it, Star it, Please. 😂
131
star
9

nuxt3-starter

💚 A Better Nuxt 3 Starter Template,generate by nuxi.
Vue
125
star
10

monthly

📖 聚焦前端,记录过去一个月看到的优秀的文章、工具,丰富前端技术栈。每月28日更新。你可以 Watch 它,相当于订阅。
Shell
105
star
11

repository-tree

🌲Pretty display directory tree view of a GitHub repository.
Vue
71
star
12

self-hosted-app-starter

🪄 A starter for the self-hosted app, help you to build your next full-stack project. https://sha-starter.onrender.com
Go
70
star
13

svg-animation-booklet

《SVG 动画开发实战》小册
Shell
60
star
14

vue-color-wheel

🎨 A color wheel picker for Vue
Vue
49
star
15

awesome-starless

A curated list of awesome repositories with few stargazers but has a huge users.
JavaScript
45
star
16

vercel-metafy

Easily scrape metadata from websites as a service using Vercel.
TypeScript
44
star
17

vue-sfc-sandbox

Vue SFC Sandbox, Sandbox as a Vue 3 component.
Vue
42
star
18

chrome-web-bookmark

One-click turn any link into a visual web bookmark, and it looks Like Twitter cards or Notion web bookmark.
Vue
42
star
19

tech-stack.tools

🗡️ Discover our curated list of creative tools to supercharge your next project.
CSS
39
star
20

skylines

My GitHub story in 3D. View a 3D model of your GitHub contribution graph.
Vue
34
star
21

vue-sfc2esm

Transpiled Vue SFC File to ES modules.
TypeScript
28
star
22

coolshapes-vue

100+ abstract shapes with gradient for design & dev project for Vue
Vue
20
star
23

vue3-starter

🖖 A Better Vue 3 Starter Template,generate by create-vue.
Vue
16
star
24

vuepress-tailwind-theme-starter

A starter of build VuePress Theme with TailwindCss.
Stylus
15
star
25

sql-repl

🔍 Just a SQL REPL for web.
Vue
14
star
26

vuex-stateshot

💾 A State Snapshot plugin on Actions/Mutations for Vuex3.1+.
JavaScript
13
star
27

metafy-svg

Easily crawl a website's metadata and generate SVG as a service.
TypeScript
13
star
28

tailwind-pre-processor

An implementation of tailwindcss using less / stylus / Sass/SCSS.
CSS
11
star
29

vscode-folder-size

📁 Shows the current file | folder size in the status bar for Visual Studio Code
TypeScript
8
star
30

element-demi

An adapter for using Element UI with Vue 2 / 3.
JavaScript
7
star
31

vue-library-starter

My minimal Vue library starter, built on top of Vite & Vue 3
Vue
7
star
32

yii2-guide-cn

Yii2.0 中文指南,Yii2.0 权威指南,Yii2.0 开发教程。
PHP
5
star
33

vue-digit-animation

A digit animation component with wheel/slide effect for Vue 3.
Vue
5
star
34

vue-dashboard

Build A Vue Dashboard Using Cube.js.
Vue
4
star
35

bugshot

团队内部使用,一款可以提交Bug附带截图功能到Redmine的Chrome插件。
JavaScript
4
star
36

algo-data-structures-patterns

📖 Learn data structures、algorithms、patterns using JavaScript.
JavaScript
3
star
37

vue-number-spinner

Number spinner component for Vue.js.
JavaScript
3
star
38

my-first-web3-demo

[WIP] Just for learning Web 3 Tech Stack.
Vue
2
star
39

netlify-metafy

Easily scrape metadata from websites as a service using Netlify.
JavaScript
2
star
40

vuepress-plugin-svg-sprite

🔌SVG Sprite plugin for Vuepress generate with svg-sprite-loader and optimised with svgo-loader
JavaScript
2
star
41

transpile-vue-sfc-to-es-modules

Transpile Vue SFC To ES Modules Slides, Built On Top Of Slidev.
CSS
2
star
42

t-to-g

1
star
43

marketing-website-demo

TypeScript
1
star
44

vue-i18n-practice

A Vue 3 demo for taking some practice use vue-i18n.
Vue
1
star
45

vite-vue2-template

⚡️ Starter template with Vite + Vue2, also support `<script setup>` style.
Vue
1
star
46

taro-echarts-sample

基于Taro使用ECharts示例
JavaScript
1
star
47

wepy-douban-demo

Just another douban weapp demo.
Vue
1
star
48

effective-javascript

68 Specific ways to harness the power of javascript.
1
star
49

image-hub-2021

My personal image hub for 2021.
1
star
50

vuepress-plugin-hero-pattern

🌠A Hero Patterns achievement for VuePress
Vue
1
star
51

astrolabe

Manage your GitHub Stars with One App
Vue
1
star
52

csspen

An interactive CSS demo with live editor and preview. build with Vue.js.
1
star