Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Create advocates filter #1122

Merged
merged 77 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
a1f0512
update styles
techtolentino Nov 2, 2020
9389a88
update icons
techtolentino Nov 2, 2020
6fadd84
Adds Goyo to codeowners file
y4izus Nov 3, 2020
e458b43
update svgs, add prop, and update styles
techtolentino Nov 3, 2020
f6a4cea
Merge branch 'master' of github.com:Qiskit/qiskit.org
y4izus Nov 4, 2020
a01580e
update styles
techtolentino Nov 2, 2020
b71140c
update icons
techtolentino Nov 2, 2020
b8a4823
update svgs, add prop, and update styles
techtolentino Nov 3, 2020
529f6a5
Adds Advocates page header (#1078)
techtolentino Nov 4, 2020
a664194
remove fileType prop
techtolentino Nov 4, 2020
df5a95d
remove class, fix prop types
techtolentino Nov 4, 2020
3ca4bba
add empty alt val
techtolentino Nov 4, 2020
0c116fa
remove unused icon
techtolentino Nov 4, 2020
03eb76d
remove copy class, add title height
techtolentino Nov 4, 2020
0b3a9f2
remove unused directives, fix styling
techtolentino Nov 4, 2020
7a3ab3f
fix title alignment
techtolentino Nov 5, 2020
9c808c2
rm overlap style
techtolentino Nov 5, 2020
4dd5cf3
Adds Advocates page header (#1078)
techtolentino Nov 4, 2020
5eb877f
Merge branch 'feature/update-advocates-page' of github.com:Qiskit/qis…
y4izus Nov 5, 2020
f998cae
Includes the <client-only> on the AppMultiselect component
y4izus Nov 4, 2020
2ef78b3
Adds MeetTheAdvocates section
y4izus Nov 5, 2020
c8bb5ea
Create AppCheckbox component
y4izus Nov 5, 2020
0f81132
Adds TODO comment on AppCheckbox
y4izus Nov 5, 2020
1266cd1
Uses AppCheckbox on MeetTheAdvocates
y4izus Nov 5, 2020
f178525
WIP Creates a layout for extra filters and results and use it on advo…
y4izus Nov 5, 2020
fb03499
Refactor and clean code
y4izus Nov 5, 2020
5b78849
Fixes v-bind
y4izus Nov 5, 2020
050d7cd
Includes types and functions to format options on the proper component
y4izus Nov 5, 2020
4ad2558
Fixes linting
y4izus Nov 5, 2020
21f7f82
fix merge conflict
techtolentino Nov 5, 2020
b5b53b3
Merge pull request #1079 from techtolentino/rt-1076-implement-advocat…
korgan00 Nov 5, 2020
304c1ce
Fixes typos on AppCheckbox component
y4izus Nov 6, 2020
0d7fab9
Replace change-on-multi-select event with change-selection
y4izus Nov 6, 2020
9d95861
Sets regions on advocates page to match regions on the events page
y4izus Nov 6, 2020
32477d8
Merge pull request #1087 from y4izus/yg-implements-meet-advocates-layout
korgan00 Nov 9, 2020
d4dc6a4
Add join section (#1089)
techtolentino Nov 10, 2020
7161ccd
Update advocate card (#1101)
korgan00 Nov 12, 2020
d374099
Simple infinite scrolling implementation used on MeetTheAdvocates com…
korgan00 Nov 12, 2020
ec7bdaf
Recover advocates from airtable (#1100)
y4izus Nov 12, 2020
1ec3c60
refactor: define custom checkbox style globally
eddybrando Nov 17, 2020
e1621be
feat: filter advocates by location
eddybrando Nov 17, 2020
b62d220
feat: support filtering advocates in small viewports
eddybrando Nov 17, 2020
113791a
refactor: move advocate interface
eddybrando Nov 17, 2020
fe5bfa1
Get advocates with slackId info (#1111)
techtolentino Nov 18, 2020
b46cb95
chore: be consistent with array type definition in file
eddybrando Nov 18, 2020
3c42aea
refactor: move Advocate interface to `/types/`
eddybrando Nov 19, 2020
a73fcd0
refactor: type check Vuex and commit mutation in action
eddybrando Nov 19, 2020
a012a88
feat: filter advocates in Vuex
eddybrando Nov 19, 2020
b0a6c43
feat: sync advocates filters in component and Vuex store
eddybrando Nov 19, 2020
396d3da
Merge remote-tracking branch 'upstream/feature/update-advocates-page'…
eddybrando Nov 19, 2020
7677d32
chore: add `slackUsername`
eddybrando Nov 19, 2020
46ddb88
chore: revert changes to Advocate interface refactory
eddybrando Nov 20, 2020
d670b88
test: add advocates "setAdvocates" tests
eddybrando Dec 3, 2020
da41771
test: add advocates "setRegionFilters" tests
eddybrando Dec 3, 2020
2769c7e
test: add advocates "fetchAdvocates" tests
eddybrando Dec 3, 2020
50bedf2
style: lint fix
eddybrando Dec 3, 2020
a515c4a
test: add advocates "updateRegionFilters" tests
eddybrando Dec 3, 2020
3169d87
test: add advocates "filteredAdvocates" tests
eddybrando Dec 3, 2020
a88fe34
feat: use "State" type
eddybrando Dec 7, 2020
525c6a9
style: remove commas
eddybrando Dec 7, 2020
e7a0994
refactor: rename variables and add JSDocs
eddybrando Dec 7, 2020
55120aa
refactor: create semantic variable
eddybrando Dec 7, 2020
a045930
refactor: commit mutation from component without action
eddybrando Dec 8, 2020
2744268
refactor: simplify filters state
eddybrando Dec 8, 2020
9626743
test: simplify tests
eddybrando Dec 8, 2020
67dd7a5
test: update test description
eddybrando Dec 8, 2020
74bbea2
test: rename mock variables and use generators
eddybrando Dec 9, 2020
0e5caa1
test: remove misleading test for old functionality
eddybrando Dec 9, 2020
524769d
test: create clean Vuex stores for each test
eddybrando Dec 10, 2020
c969e0e
test: more "mutations" after "getters"
eddybrando Dec 10, 2020
ac28704
refactor: reorder 1. getters, 2. mutations, 3. actions
eddybrando Dec 10, 2020
50e1d4b
test: replace unnecessary functions
eddybrando Dec 10, 2020
fbb5f73
test: rename "cloneDeep"
eddybrando Dec 10, 2020
400de59
Merge branch 'feature/update-advocates-page' into ev-issue-1086-advoc…
eddybrando Dec 10, 2020
f84fdfd
Merge branch 'feature/update-advocates-page' into ev-issue-1086-advoc…
eddybrando Dec 10, 2020
a2dc84f
style: lint fix
eddybrando Dec 10, 2020
fa11cb2
style: lint fix
eddybrando Dec 10, 2020
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
12 changes: 11 additions & 1 deletion assets/scss/carbon/community-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,14 @@ $logo-size-small: 8rem;
$icon-size: 0.75rem;

$carbon--theme: $carbon--theme--custom;
@include carbon--theme();
@include carbon--theme();

//== Checkbox
eddybrando marked this conversation as resolved.
Show resolved Hide resolved

.bx--checkbox:focus + .bx--checkbox-label::before {
box-shadow: 0 0 0 2px $white, 0 0 0 4px $purple-60;
}

.bx--checkbox-label::before {
border: 1px solid $black-100;
}
58 changes: 48 additions & 10 deletions components/advocates/MeetTheAdvocates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@
<template slot="filters-on-m-l-screen">
<AppFieldset :label="filter.label">
<client-only>
<AppCheckbox
<cv-checkbox
v-for="option in filter.options"
:key="option"
:option="option"
:checked="isRegionFilterChecked(option)"
:label="option"
:value="option"
@change="updateRegionFilter(option, $event)"
/>
</client-only>
</AppFieldset>
</template>
<template slot="filters-on-s-screen">
<AppMultiSelect v-bind="filter" />
<AppMultiSelect
:label="filter.label"
:options="filter.options"
:value="regionFilters"
@change-selection="updateRegionFilters($event)"
/>
</template>
<template slot="results">
<InfiniteScroll
Expand All @@ -44,33 +52,63 @@

<script lang="ts">
import Vue from 'vue'
import { mapState, MapperForStateWithNamespace } from 'vuex'
import { Component, Prop } from 'vue-property-decorator'
import AdvocateCard from '~/components/advocates/AdvocateCard.vue'
import AppMultiSelect from '~/components/ui/AppMultiSelect.vue'
import AppFieldset from '~/components/ui/AppFieldset.vue'
import AppCheckbox from '~/components/ui/AppCheckbox.vue'
import AppFiltersResultsLayout from '~/components/ui/AppFiltersResultsLayout.vue'
import InfiniteScroll from '~/components/ui/InfiniteScroll.vue'
import AppLink from '~/components/ui/AppLink.vue'
import { Advocate, ADVOCATES_WORLD_REGION_OPTIONS, State } from '~/store/modules/advocates.ts'

@Component({
components: {
AdvocateCard,
AppMultiSelect,
AppFieldset,
AppCheckbox,
AppFiltersResultsLayout,
InfiniteScroll,
AppLink
},

computed: {
...mapState<MapperForStateWithNamespace>('advocates', {
regionFilters: (state: State) => state.regionFilters
})
}
})
export default class extends Vue {
@Prop(Array) advocates!: any
export default class MeetTheAdvocates extends Vue {
@Prop(Array) advocates!: Advocate[]

/**
* Region filters from Vuex store.
*
* Initialized with mapState.
*/
public regionFilters!: string[]

filter = {
private filter = {
label: 'Locations',
options: ['Americas', 'Asia Pacific', 'Europe', 'Africa'],
filterType: 'regionFilters'
options: ADVOCATES_WORLD_REGION_OPTIONS
}

isRegionFilterChecked (filterValue: string): boolean {
return this.regionFilters.includes(filterValue)
}

updateRegionFilter (option: string, isChecked: boolean): void {
const regionFilters = this.regionFilters.filter(oldOption => oldOption !== option)

if (isChecked) {
regionFilters.push(option)
}

this.updateRegionFilters(regionFilters)
}

updateRegionFilters (regionFilters: string[]): void {
this.$store.commit('advocates/setRegionFilters', regionFilters)
}

joinSlackLink: string = 'https://ibm.co/joinqiskitslack'
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@nuxtjs/axios": "^5.12.3",
"carbon-components": "^10.25.0",
"cross-env": "^7.0.3",
"lodash": "^4.17.20",
"nuxt": "^2.14.10",
"nuxt-lazy-load": "^1.2.4",
"ts-node": "^9.1.1",
Expand All @@ -43,6 +44,7 @@
"@nuxtjs/style-resources": "^1.0.0",
"@types/airtable": "^0.8.1",
"@types/jest": "^26.0.18",
"@types/lodash": "^4.14.165",
"@types/markdown-it": "^10.0.3",
"@types/markdown-it-anchor": "^4.0.4",
"@types/markdown-it-link-attributes": "^3.0.0",
Expand Down
14 changes: 3 additions & 11 deletions pages/advocates/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>

<script lang="ts">
import { mapGetters, mapActions } from 'vuex'
import { mapGetters } from 'vuex'
import { Component } from 'vue-property-decorator'
import QiskitPage from '~/components/logic/QiskitPage.vue'

Expand All @@ -19,21 +19,13 @@ import QiskitPage from '~/components/logic/QiskitPage.vue'
},

computed: {
...mapGetters([
...mapGetters('advocates', [
'filteredAdvocates'
])
},

methods: {
...mapActions({
fetchAdvocates: 'fetchAdvocates'
})
},

async fetch ({ store }) {
const advocates = await store.dispatch('fetchAdvocates')

store.commit('setAdvocates', advocates)
await store.dispatch('advocates/fetchAdvocates')
}
})
export default class AdvocatesPage extends QiskitPage {
Expand Down
6 changes: 4 additions & 2 deletions store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import learningResources from './modules/learning-resources'

Vue.use(Vuex)

export default () => new Vuex.Store({
export const storeOptions = {
modules: { events, advocates, learningResources }
})
}

export default () => new Vuex.Store(storeOptions)
80 changes: 53 additions & 27 deletions store/modules/advocates.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ActionTree, GetterTree, MutationTree } from 'vuex'

const ADVOCATES_WORLD_REGIONS = Object.freeze({
northAmerica: 'North America',
southAmerica: 'South America',
Expand All @@ -9,14 +11,18 @@ const ADVOCATES_WORLD_REGIONS = Object.freeze({

type AdvocatesWorldRegion = typeof ADVOCATES_WORLD_REGIONS[keyof typeof ADVOCATES_WORLD_REGIONS]

type Advocate = {
name: string,
image: string,
city: string,
country: string,
region: AdvocatesWorldRegion,
slackId: string,
slackUsername: string
/**
* Interface for a Qiskit advocate.
*/
interface Advocate {
city: string
country: string
image: string
location?: string
name: string
region: AdvocatesWorldRegion
slackId?: string
eddybrando marked this conversation as resolved.
Show resolved Hide resolved
slackUsername?: string
}

const ADVOCATES_WORLD_REGION_OPTIONS = Object.freeze([
Expand All @@ -35,28 +41,48 @@ export {
Advocate
}

export default {
state () {
return {
advocates: []
}
},
getters: {
filteredAdvocates (state: any) {
const { advocates } = state
export class State {
advocates: Advocate[] = []
regionFilters: string[] = []
}

const getters = <GetterTree<State, any>> {
/**
* List of advocates filtered by selected regions.
*/
filteredAdvocates ({ advocates, regionFilters }): Advocate[] {
const noRegionFilters = regionFilters.length === 0

if (noRegionFilters) {
return advocates
}

return advocates.filter(advocate => regionFilters.includes(advocate.region))
}
}

const mutations = <MutationTree<State>> {
setAdvocates (state, advocates: Advocate[]) {
state.advocates = advocates
},
mutations: {
setAdvocates (state: any, payload: any) {
state.advocates = payload
}
},
actions: {
async fetchAdvocates () {
const advocatesModule = await import('~/content/advocates/advocates.json')
return advocatesModule.default || []
}

setRegionFilters (state, regionFilters: string[]) {
state.regionFilters = regionFilters
}
}

const actions = <ActionTree<State, any>> {
async fetchAdvocates ({ commit }): Promise<void> {
const advocatesModule = await import('~/content/advocates/advocates.json')
const advocates = advocatesModule.default || []
commit('setAdvocates', advocates)
}
}

export default {
namespaced: true,
state: new State(),
actions,
mutations,
getters
}
6 changes: 0 additions & 6 deletions store/modules/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ type CommunityEvent = {
to: string
}

type EventMultiSelectOption = {
label: string,
value: string,
name: string
}

type EventPayload = {
events: string,
eventsSet: CommunityEvent[]
Expand Down
Loading