Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andoshin11 committed Dec 10, 2018
0 parents commit 2c8f0b6
Show file tree
Hide file tree
Showing 24 changed files with 8,058 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
24 changes: 24 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,24 @@
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'plugin:vue/recommended',
'plugin:prettier/recommended'
],
// required to lint *.vue files
plugins: [
'vue',
'prettier'
],
// add your custom rules here
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}
81 changes: 81 additions & 0 deletions .gitignore
@@ -0,0 +1,81 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# Nuxt generate
dist

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# IDE
.idea
4 changes: 4 additions & 0 deletions .prettierrc
@@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}
22 changes: 22 additions & 0 deletions README.md
@@ -0,0 +1,22 @@
# nuxt-ts-example

> My praiseworthy Nuxt.js project
## Build Setup

``` bash
# install dependencies
$ yarn install

# serve with hot reload at localhost:3000
$ yarn run dev

# build for production and launch server
$ yarn run build
$ yarn start

# generate static project
$ yarn run generate
```

For detailed explanation on how things work, checkout [Nuxt.js docs](https://nuxtjs.org).
55 changes: 55 additions & 0 deletions nuxt.config.js
@@ -0,0 +1,55 @@
const extendConfig = require('./webpack.config.extend')
const pkg = require('./package')

module.exports = {
mode: 'universal',
srcDir: 'src/',

/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},

/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },

/*
** Global CSS
*/
css: [],

/*
** Extensions
*/
extensions: ['ts', 'js'],

/*
** Plugins to load before mounting the App
*/
plugins: [],

/*
** Nuxt.js modules
*/
modules: [],

/*
** Build configuration
*/
build: {
extend(config) {
extendConfig(config)
return
}
}
}
33 changes: 33 additions & 0 deletions package.json
@@ -0,0 +1,33 @@
{
"name": "nuxt-ts-example",
"version": "1.0.0",
"description": "My praiseworthy Nuxt.js project",
"author": "andoshin11",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development nodemon src/server/index.js --watch server",
"build": "nuxt build",
"start": "cross-env NODE_ENV=production node src/server/index.js",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint"
},
"dependencies": {
"cross-env": "^5.2.0",
"express": "^4.16.3",
"nuxt": "^2.0.0"
},
"devDependencies": {
"@types/node": "^10.12.12",
"babel-eslint": "^8.2.1",
"eslint": "^5.0.1",
"eslint-config-prettier": "^3.1.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-prettier": "2.6.2",
"eslint-plugin-vue": "^4.0.0",
"nodemon": "^1.11.0",
"prettier": "1.14.3",
"ts-loader": "^5.3.1",
"typescript": "^3.2.2"
}
}
7 changes: 7 additions & 0 deletions src/assets/README.md
@@ -0,0 +1,7 @@
# ASSETS

**This directory is not required, you can delete it if you don't want to use it.**

This directory contains your un-compiled assets such as LESS, SASS, or JavaScript.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked).
76 changes: 76 additions & 0 deletions src/components/Calculator.vue
@@ -0,0 +1,76 @@
<template>
<div class="Calculator">
<input type="number" class="left" v-model="left">
<select name="operator" v-model="operator">
<option :value="Operators.ADD">+</option>
<option :value="Operators.SUBTRACT">-</option>
<option :value="Operators.MULTIPLE">*</option>
<option :value="Operators.DEVIDE">/</option>
</select>
<input type="number" class="right" v-model="right">
<div class="answer">= {{ answer }}</div>
</div>
</template>

<script lang="ts">
import Vue from 'vue'
enum Operators {
ADD,
SUBTRACT,
MULTIPLE,
DEVIDE
}
interface IData {
Operators: typeof Operators
left: string | null
right: string | null
operator: Operators
}
export default Vue.extend({
data(): IData {
return {
Operators,
left: null,
right: null,
operator: Operators.ADD
}
},
computed: {
answer(): number {
if (!this.left || !this.right) return 0
const left = Number(this.left)
const right = Number(this.right)
switch (this.operator) {
case Operators.ADD:
return left + right
case Operators.SUBTRACT:
return left - right
case Operators.MULTIPLE:
return left * right
case Operators.DEVIDE:
return left / right
default:
return 0
}
}
}
})
</script>

<style scoped>
.Calculator {
display: flex;
justify-content: center;
margin-top: 16px;
}
input {
border: solid 1px #ddd;
margin: 0 8px;
}
</style>

0 comments on commit 2c8f0b6

Please sign in to comment.