Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue step 3 #1584

Open
wants to merge 7 commits into
base: vue-step-3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules
/dist

# local env files
.env
.env.local
.env.*.local

Expand Down
26 changes: 26 additions & 0 deletions apollo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const path = require('path');

// Load .env files
const { loadEnv } = require('vue-cli-plugin-apollo/utils/load-env');
const env = loadEnv([
path.resolve(__dirname, '.env'),
path.resolve(__dirname, '.env.local')
]);

module.exports = {
client: {
service: env.VUE_APP_APOLLO_ENGINE_SERVICE,
includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}']
},
service: {
name: env.VUE_APP_APOLLO_ENGINE_SERVICE,
localSchemaFile: path.resolve(
__dirname,
'./node_modules/.temp/graphql/schema.json'
)
},
engine: {
endpoint: process.env.APOLLO_ENGINE_API_ENDPOINT,
apiKey: env.VUE_APP_APOLLO_ENGINE_KEY
}
};
21 changes: 13 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"ci-check": "yarn format:diff",
"format:diff": "prettier --list-different \"src/**/*.{js,vue,scss}\"",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint",
"test:unit": "vue-cli-service test:unit"
"ci-check": "yarn format:diff",
"format:diff": "prettier --list-different \"src/**/*.{js,vue,scss}\""
},
"dependencies": {
"@carbon/icons-vue": "^10.30.0",
Expand All @@ -17,6 +17,7 @@
"core-js": "^3.11.0",
"mock-apollo-client": "^1.1.0",
"vue": "^2.6.12",
"vue-apollo": "^3.0.0-beta.11",
"vue-router": "^3.5.1"
},
"devDependencies": {
Expand All @@ -31,13 +32,12 @@
"eslint": "^7.25.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.9.0",
"graphql-tag": "^2.9.0",
"sass": "^1.32.11",
"sass-loader": "^10.1.1",
"vue-cli-plugin-apollo": "~0.22.2",
"vue-template-compiler": "^2.6.12"
},
"prettier": {
"singleQuote": true
},
"eslintConfig": {
"root": true,
"env": {
Expand All @@ -52,6 +52,9 @@
"parser": "babel-eslint"
}
},
"prettier": {
"singleQuote": true
},
"postcss": {
"plugins": {
"autoprefixer": {}
Expand All @@ -68,8 +71,10 @@
"json",
"vue"
],
"setupFiles": ["./tests/setup.js"],
"transform": {
"setupFiles": [
"./tests/setup.js"
],
"transform": {
"^.+\\.vue$": "vue-jest",
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
"^.+\\.jsx?$": "babel-jest"
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import App from './App.vue';
import router from './router';

import CarbonComponentsVue from '@carbon/vue';
import { createProvider } from './vue-apollo';
Vue.use(CarbonComponentsVue);

Vue.config.productionTip = false;

new Vue({
router,
apolloProvider: createProvider(),
render: h => h(App)
}).$mount('#app');
2 changes: 1 addition & 1 deletion src/styles/_carbon.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$feature-flags: (
grid-columns-16: true,
grid-columns-16: true
);

@import 'carbon-components/scss/globals/scss/styles';
Expand Down
2 changes: 1 addition & 1 deletion src/views/LandingPage/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

> * {
// lift above position absolute
position: relative;;
position: relative;
}
}
28 changes: 28 additions & 0 deletions src/views/RepoPage/LinkList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<ul class="link-list">
<li>
<cv-link :href="url">GitHub</cv-link>
</li>

<li v-if="homepageUrl">
<span>&nbsp;|&nbsp;</span>
<cv-link :href="homepageUrl">Homepage</cv-link>
</li>
</ul>
</template>

<script>
export default {
name: 'LinkList',
props: {
url: String,
homepageUrl: String
}
};
</script>

<style>
.link-list {
display: flex;
}
</style>
115 changes: 81 additions & 34 deletions src/views/RepoPage/RepoPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
<div class="bx--col-lg-16">
<repo-table
:headers="headers"
:rows="rows"
title="Carbon Repositories"
helperText="A collection of public Carbon repositories."
title="Amiyou Repositories"
helperText="A collection of public Amiyou repositories."
:loading="$apollo.loading"
:rows="pagedRows"
:totalRows="rows.length"
@pagination="onPagination"
/>
</div>
</div>
Expand All @@ -15,6 +18,41 @@

<script>
import RepoTable from './RepoTable';
import gql from 'graphql-tag';

const REPO_QUERY = gql`
query REPO_QUERY {
# Let's use carbon as our organization
organization(login: "amiyou-project") {
# We'll grab all the repositories in one go. To load more resources
# continuously, see the advanced topics.
repositories(first: 75, orderBy: { field: UPDATED_AT, direction: DESC }) {
totalCount
nodes {
url
homepageUrl
issues(filterBy: { states: OPEN }) {
totalCount
}
stargazers {
totalCount
}
releases(first: 1) {
totalCount
nodes {
name
}
}
name
updatedAt
createdAt
description
id
}
}
}
}
`;

const headers = [
{
Expand Down Expand Up @@ -43,44 +81,53 @@ const headers = [
}
];

const rows = [
{
id: '1',
name: 'Repo 1',
createdAt: 'Date',
updatedAt: 'Date',
issueCount: '123',
stars: '456',
links: 'Links'
},
{
id: '2',
name: 'Repo 2',
createdAt: 'Date',
updatedAt: 'Date',
issueCount: '123',
stars: '456',
links: 'Links'
},
{
id: '3',
name: 'Repo 3',
createdAt: 'Date',
updatedAt: 'Date',
issueCount: '123',
stars: '456',
links: 'Links'
}
];

export default {
name: 'RepoPage',
components: { RepoTable },
data() {
return {
headers,
rows
pageSize: 0,
pageStart: 0,
page: 0
};
},
apollo: {
organization: REPO_QUERY
},
watch: {
rows() {
if (this.organization) {
console.dir(this.organization.repositories.nodes);
}
}
},
computed: {
rows() {
if (!this.organization) {
return [];
} else {
return this.organization.repositories.nodes.map(row => ({
...row,
key: row.id,
stars: row.stargazers.totalCount,
issueCount: row.issues.totalCount,
createdAt: new Date(row.createdAt).toLocaleDateString(),
updatedAt: new Date(row.updatedAt).toLocaleDateString(),
links: { url: row.url, homepageUrl: row.homepageUrl }
}));
}
},
pagedRows() {
return this.rows.slice(this.pageStart, this.pageStart + this.pageSize);
}
},
methods: {
onPagination(val) {
this.pageSize = val.length;
this.pageStart = val.start - 1;
this.page = val.page;
}
}
};
</script>
31 changes: 27 additions & 4 deletions src/views/RepoPage/RepoTable.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
<template>
<cv-data-table :columns="columns" :title="title" :helper-text="helperText">
<cv-data-table-skeleton
v-if="loading"
:columns="columns"
:title="title"
:helper-text="helperText"
:rows="10"
/>
<cv-data-table
v-else
:columns="columns"
:title="title"
:helper-text="helperText"
:pagination="{ numberOfItems: this.totalRows }"
@pagination="$emit('pagination', $event)"
>
<template v-slot:data>
<cv-data-table-row v-for="(row, rowIndex) in data" :key="`${rowIndex}`">
<cv-data-table-cell
v-for="(cell, cellIndex) in row.data"
:key="`${cellIndex}`"
>{{ cell }}</cv-data-table-cell
>
<template v-if="!cell.url">
{{ cell }}
</template>
<link-list v-else :url="cell.url" :homepage-url="cell.homepageUrl" />
</cv-data-table-cell>
<template v-slot:expandedContent> {{ row.description }} xx </template>
</cv-data-table-row>
</template>
</cv-data-table>
</template>

<script>
import LinkList from './LinkList';

export default {
name: 'RepoTable',
props: {
headers: Array,
rows: Array,
title: String,
helperText: String
helperText: String,
loading: Boolean,
totalRows: Number
},
components: { LinkList },
computed: {
columns() {
return this.headers.map(header => header.header);
Expand All @@ -36,7 +59,7 @@ export default {
row.stars,
row.links
],
description: 'Row description'
description: row.description
}));
}
}
Expand Down
Loading