Skip to content

Commit

Permalink
feat(#83): add map component
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Jul 5, 2023
1 parent aac47b4 commit 2af00e7
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/Map.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import CTMap from './Map.vue'

export default {
title: 'CivicTheme/Molecules/Map',
component: CTMap,
argTypes: {
theme: {
options: ['dark', 'light'],
control: 'select'
},
},
parameters: {
status: {
type: 'beta',
}
}
}

const Template = (args, { argTypes }) => {
return {
props: Object.keys(argTypes),
template: `<CTMap v-bind="$props" v-on="$props" />`,
}
}

export const Default = Template.bind({})
Default.storyName = 'Map'
Default.args = {
address: 'Australia',
url: 'https://maps.google.com/maps?q=australia&t=&z=3&ie=UTF8&iwloc=&output=embed',
viewUrl: 'http://example.com/tublm'
}
60 changes: 60 additions & 0 deletions src/components/Map.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<div :class="`ct-map ${themeClass}`">
<div class="container">
<div class="row">
<div class="col-xxs-12">
<div class="ct-map__canvas">
<CTIFrame
class="ct-map__iframe"
:src="url"
:title="address"
/>
</div>

<CTButton
v-if="viewUrl"
class="ct-map__link"
icon="upper-right-arrow"
kind="link"
text="View in Google Maps"
:theme="theme"
type="tertiary"
:url="viewUrl"
/>
</div>
</div>
</div>
</div>
</template>

<script>
import ThemeMixin from '../mixins/theme'
export default {
mixins: [ThemeMixin],
props: {
url: {
address: String,
default: undefined
},
url: {
type: String,
required: true
},
viewUrl: {
type: String,
default: undefined
}
},
// computed: {
// icon: ({ type }) => ({
// error: 'close-outline',
// information: 'information-mark',
// warning: 'exclamation-mark-1',
// success: 'approve'
// }[type] || 'information-mark')
// }
}
</script>
16 changes: 16 additions & 0 deletions test/components/Map.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* global cy, describe, it */
import Button from '../../src/components/Map.vue'

describe('Molecules/Map', () => {
it('Default', () => {
cy.standardComponentTest(Button, {
mountOptions: {
propsData: {
address: 'Australia',
url: 'https://maps.google.com/maps?q=australia&t=&z=3&ie=UTF8&iwloc=&output=embed',
viewUrl: 'http://example.com/tublm'
}
}
})
})
})

0 comments on commit 2af00e7

Please sign in to comment.