├── .gitattributes ├── .gitignore ├── example ├── index.js ├── App.css └── App.vue ├── babel.config.js ├── .editorconfig ├── bili.config.ts ├── themes └── default.css ├── circle.yml ├── types └── vue-slim-tabs.d.ts ├── LICENSE ├── package.json ├── src └── index.js └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist/ 3 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | new Vue({ 5 | el: '#app', 6 | render: h => h(App) 7 | }) 8 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | "poi/babel", 5 | { 6 | jsx: "vue" 7 | } 8 | ] 9 | ] 10 | }; 11 | -------------------------------------------------------------------------------- /example/App.css: -------------------------------------------------------------------------------- 1 | #app { 2 | max-width: 600px; 3 | margin: 0 auto; 4 | } 5 | 6 | .fade { 7 | color: #999; 8 | font-size: 12px; 9 | } 10 | 11 | .enable-angular { 12 | user-select: none; 13 | } 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /bili.config.ts: -------------------------------------------------------------------------------- 1 | import { Config } from 'bili' 2 | 3 | const config: Config = { 4 | output: { 5 | format: ['cjs', 'umd', 'esm'], 6 | fileName({ format }) { 7 | if (format === 'umd') { 8 | return 'vue-slim-tabs.js' 9 | } 10 | return 'vue-slim-tabs.[format].js' 11 | }, 12 | moduleName: 'VueSlimTabs' 13 | }, 14 | banner: true 15 | } 16 | 17 | export default config 18 | -------------------------------------------------------------------------------- /themes/default.css: -------------------------------------------------------------------------------- 1 | .vue-tablist { 2 | list-style: none; 3 | display: flex; 4 | padding-left: 0; 5 | border-bottom: 1px solid #e2e2e2; 6 | } 7 | 8 | .vue-tab { 9 | padding: 5px 10px; 10 | cursor: pointer; 11 | user-select: none; 12 | border: 1px solid transparent; 13 | border-bottom-color: #e2e2e2; 14 | border-radius: 3px 3px 0 0; 15 | background-color: white; 16 | position: relative; 17 | bottom: -1px; 18 | } 19 | 20 | .vue-tab[aria-selected="true"] { 21 | border-color: #e2e2e2; 22 | border-bottom-color: transparent; 23 | } 24 | 25 | .vue-tab[aria-disabled="true"] { 26 | cursor: not-allowed; 27 | color: #999; 28 | } 29 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: ~/repo 5 | docker: 6 | - image: circleci/node:latest 7 | branches: 8 | ignore: 9 | - gh-pages # list of branches to ignore 10 | - /release\/.*/ # or ignore regexes 11 | steps: 12 | - checkout 13 | - restore_cache: 14 | key: dependency-cache-{{ checksum "yarn.lock" }} 15 | - run: 16 | name: install dependences 17 | command: yarn 18 | - save_cache: 19 | key: dependency-cache-{{ checksum "yarn.lock" }} 20 | paths: 21 | - ./node_modules 22 | - run: 23 | name: test 24 | command: yarn test 25 | - run: 26 | name: release 27 | command: npx semantic-release 28 | -------------------------------------------------------------------------------- /types/vue-slim-tabs.d.ts: -------------------------------------------------------------------------------- 1 | import { PluginFunction, VueConstructor } from 'vue'; 2 | 3 | export const Tabs: TabsConstructor; 4 | export const Tab: TabConstructor; 5 | export const install: PluginFunction<{}>; 6 | 7 | export interface TabsProps { 8 | defaultIndex?: number; 9 | onSelect?: (val: any) => void; 10 | } 11 | 12 | export interface TabsData { 13 | selectedIndex: number; 14 | } 15 | 16 | export interface TabsMethods { 17 | switchTab: (e: Event, index: number, isDisabled: boolean) => void; 18 | } 19 | 20 | export interface TabProps { 21 | title?: string; 22 | titleSlot?: string; 23 | disabled?: boolean; 24 | } 25 | 26 | export interface TabsConstructor extends VueConstructor { 27 | props: TabsProps; 28 | data: () => TabsData; 29 | methods: TabsMethods; 30 | } 31 | 32 | export interface TabConstructor extends VueConstructor { 33 | props: TabProps; 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) egoist <0x142857@gmail.com> (https://egoistian.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-slim-tabs", 3 | "version": "0.3.0", 4 | "description": "Simple tabs component for Vue.js", 5 | "repository": { 6 | "url": "egoist/vue-slim-tabs", 7 | "type": "git" 8 | }, 9 | "module": "dist/vue-slim-tabs.esm.js", 10 | "main": "dist/vue-slim-tabs.cjs.js", 11 | "unpkg": "dist/vue-slim-tabs.js", 12 | "jsdelivr": "dist/vue-slim-tabs.js", 13 | "cdn": "dist/vue-slim-tabs.js", 14 | "types": "types/vue-slim-tabs.d.ts", 15 | "poi": { 16 | "entry": "example/index.js", 17 | "output": { 18 | "dir": "example/dist" 19 | } 20 | }, 21 | "files": [ 22 | "dist", 23 | "themes", 24 | "types" 25 | ], 26 | "scripts": { 27 | "test": "echo 'no tests!' && npm run lint", 28 | "prepublish": "npm run build", 29 | "lint": "xo", 30 | "build": "bili", 31 | "build:example": "poi --prod", 32 | "dev": "poi -so" 33 | }, 34 | "author": "egoist <0x142857@gmail.com>", 35 | "license": "MIT", 36 | "dependencies": {}, 37 | "devDependencies": { 38 | "bili": "^4.8.0", 39 | "eslint-config-prettier": "^6.1.0", 40 | "eslint-config-rem": "^4.0.0", 41 | "eslint-plugin-prettier": "^3.1.0", 42 | "poi": "^12.6.10", 43 | "prettier": "^1.18.2", 44 | "vue": "^2.6.10", 45 | "vue-github-badge": "^1.0.0", 46 | "vue-template-compiler": "^2.6.10", 47 | "xo": "^0.24.0" 48 | }, 49 | "xo": { 50 | "extends": [ 51 | "rem", 52 | "plugin:prettier/recommended" 53 | ], 54 | "ignores": [ 55 | "example/**" 56 | ] 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | export const Tabs = { 2 | name: "tabs", 3 | props: { 4 | defaultIndex: { 5 | default: 0, 6 | type: Number 7 | }, 8 | onSelect: { 9 | type: Function 10 | } 11 | }, 12 | data() { 13 | return { 14 | selectedIndex: this.defaultIndex 15 | }; 16 | }, 17 | methods: { 18 | switchTab(e, index, isDisabled) { 19 | if (!isDisabled) { 20 | this.selectedIndex = index; 21 | this.onSelect && this.onSelect(e, index); 22 | } 23 | } 24 | }, 25 | render() { 26 | const tabs = this.$slots.default.filter( 27 | component => component.componentOptions 28 | ); 29 | 30 | const tabList = []; 31 | tabs.forEach((child, index) => { 32 | const { title, titleSlot, disabled } = child.componentOptions.propsData; 33 | const content = titleSlot ? this.$slots[titleSlot] : title; 34 | const isDisabled = disabled === true || disabled === ""; 35 | 36 | tabList.push( 37 |
6 | A slim tab component for Vue.js, brought by 7 | EGOIST 8 | 9 |
10 |11 | > 1.3 kB minified (418 bytes gzipped). 12 |
13 | 16 |Vue (pronounced /vjuː/, like 22 | view) is a 23 | progressive framework for building user interfaces. Unlike other monolithic frameworks, Vue is designed from the ground up to be incrementally adoptable. The core library is focused on the view layer only, and is very easy to pick up and integrate with other libraries or existing projects. On the other hand, Vue is also perfectly capable of powering sophisticated Single-Page Applications when used in combination with modern tooling and supporting libraries.
24 |React and Vue share many similarities. They both:
28 |Being so similar in scope, we’ve put more time into fine-tuning this comparison than any other. We want to ensure not only technical accuracy, but also balance. We point out where React outshines Vue, for example in the richness of their ecosystem and abundance of their custom renderers.
34 |If you've ever built a JavaScript application, the chances are you've encountered – or at least heard of – frameworks like React, Angular, Vue and Ractive. Like Svelte, these tools all share a goal of making it easy to build slick interactive user interfaces.
38 |But Svelte has a crucial difference: rather than interpreting your application code at 39 | run time, your app is converted into ideal JavaScript at 40 | build time. That means you don't pay the performance cost of the framework's abstractions, or incur a penalty when your app first loads.
41 |And because there's no overhead, you can easily adopt Svelte in an existing app incrementally, or ship widgets as standalone packages that work anywhere.
42 |