├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── img │ ├── bloodroot-leaf.jpg │ ├── cat-basking.jpg │ ├── frame.jpg │ ├── orange-blue-abstract.jpg │ └── red-tailed-hawk.jpg └── index.html └── src ├── App.vue ├── components ├── FigureFunctionalRF.js ├── FigureFunctionalSFC.vue ├── FigureStandardRF.js └── FigureStandardSFC.vue └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-functional 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/app"] 3 | }; 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-functional", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "vue": "^2.5.16" 12 | }, 13 | "devDependencies": { 14 | "@vue/cli-plugin-babel": "^3.0.0-rc.5", 15 | "@vue/cli-plugin-eslint": "^3.0.0-rc.5", 16 | "@vue/cli-service": "^3.0.0-rc.5", 17 | "@vue/eslint-config-prettier": "^3.0.0-rc.5", 18 | "vue-template-compiler": "^2.5.16" 19 | }, 20 | "eslintConfig": { 21 | "root": true, 22 | "env": { 23 | "node": true 24 | }, 25 | "extends": [ 26 | "plugin:vue/essential", 27 | "@vue/prettier" 28 | ], 29 | "rules": {}, 30 | "parserOptions": { 31 | "parser": "babel-eslint" 32 | } 33 | }, 34 | "postcss": { 35 | "plugins": { 36 | "autoprefixer": {} 37 | } 38 | }, 39 | "browserslist": [ 40 | "> 1%", 41 | "last 2 versions", 42 | "not ie <= 8" 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nabrown/vue-functional-examples/33713a4e2a9adaf054e82be2a52c9791c3181329/public/favicon.ico -------------------------------------------------------------------------------- /public/img/bloodroot-leaf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nabrown/vue-functional-examples/33713a4e2a9adaf054e82be2a52c9791c3181329/public/img/bloodroot-leaf.jpg -------------------------------------------------------------------------------- /public/img/cat-basking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nabrown/vue-functional-examples/33713a4e2a9adaf054e82be2a52c9791c3181329/public/img/cat-basking.jpg -------------------------------------------------------------------------------- /public/img/frame.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nabrown/vue-functional-examples/33713a4e2a9adaf054e82be2a52c9791c3181329/public/img/frame.jpg -------------------------------------------------------------------------------- /public/img/orange-blue-abstract.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nabrown/vue-functional-examples/33713a4e2a9adaf054e82be2a52c9791c3181329/public/img/orange-blue-abstract.jpg -------------------------------------------------------------------------------- /public/img/red-tailed-hawk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nabrown/vue-functional-examples/33713a4e2a9adaf054e82be2a52c9791c3181329/public/img/red-tailed-hawk.jpg -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | vue-functional 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 55 | 56 | 156 | -------------------------------------------------------------------------------- /src/components/FigureFunctionalRF.js: -------------------------------------------------------------------------------- 1 | export default { 2 | functional: true, 3 | props: { 4 | src: { 5 | required: true, 6 | type: String 7 | }, 8 | type: { 9 | required: true, 10 | type: String 11 | }, 12 | tags: { 13 | required: false, 14 | type: Array 15 | } 16 | }, 17 | render(createElement, {props, listeners, slots}){ 18 | 19 | const img = createElement( 20 | 'img', 21 | { 22 | 'attrs': { 23 | 'src': props.src 24 | } 25 | } 26 | ) 27 | 28 | const caption = slots().default ? createElement( 29 | 'figcaption', 30 | [ createElement('span', slots().default) ] 31 | ) : '' 32 | 33 | const tags = props.tags && (props.type != 'framed') ? createElement( 34 | 'div', 35 | {'class' : 'tags'}, 36 | props.tags.map(function (tag) { 37 | return createElement('span', tag) 38 | }) 39 | ) : '' 40 | 41 | return createElement( 42 | 'figure', 43 | { 44 | 'class': props.type, 45 | 'on' : { 46 | 'click': listeners.click 47 | } 48 | }, 49 | [img, caption, tags] 50 | ) 51 | } 52 | } -------------------------------------------------------------------------------- /src/components/FigureFunctionalSFC.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 32 | -------------------------------------------------------------------------------- /src/components/FigureStandardRF.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | props: { 4 | src: { 5 | required: true, 6 | type: String 7 | }, 8 | type: { 9 | required: true, 10 | type: String 11 | }, 12 | tags: { 13 | required: false, 14 | type: Array 15 | } 16 | }, 17 | render(createElement){ 18 | 19 | const img = createElement( 20 | 'img', 21 | { 22 | 'attrs': { 23 | 'src': this.src 24 | } 25 | } 26 | ) 27 | 28 | const caption = this.$slots.default ? createElement( 29 | 'figcaption', 30 | [ createElement('span', this.$slots.default) ] 31 | ) : '' 32 | 33 | const tags = this.tags && (this.type != 'framed') ? createElement( 34 | 'div', 35 | {'class' : 'tags'}, 36 | this.tags.map(function (tag) { 37 | return createElement('span', tag) 38 | }) 39 | ) : '' 40 | 41 | return createElement( 42 | 'figure', 43 | { 44 | 'class': this.type, 45 | 'on': { 46 | 'click' : () => { 47 | this.$emit('click') 48 | } 49 | } 50 | }, 51 | [img, caption, tags] 52 | ) 53 | } 54 | } -------------------------------------------------------------------------------- /src/components/FigureStandardSFC.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 32 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | 4 | Vue.config.productionTip = false; 5 | 6 | new Vue({ 7 | render: h => h(App) 8 | }).$mount("#app"); 9 | --------------------------------------------------------------------------------