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

feat(#70): add message component #71

Merged
merged 2 commits into from
May 23, 2023
Merged
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
38 changes: 38 additions & 0 deletions src/components/Message.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import CTMessage from './Message.vue'

export default {
title: 'CivicTheme/Organisms/Message',
component: CTMessage,
argTypes: {
theme: {
options: ['dark', 'light'],
control: 'select'
},
type: {
options: ['error', 'information', 'warning', 'success'],
control: 'select'
}
},
parameters: {
status: {
type: 'beta',
}
}
}

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

export const Default = Template.bind({})
Default.storyName = 'Message'
Default.args = {
default: 'Filium morte multavit si sine causa, nollem me tamen laudandis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus vel elit laoreet, dignissim arcu sit amet, vulputate risus.',
title: 'The information on this page is currently being updated.',
type: 'information'
}
49 changes: 49 additions & 0 deletions src/components/Message.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<template>
<div
class="ct-message"
:class="{
[themeClass]: true,
[`ct-message--${type}`]: type
}"
>
<div class="ct-message__icon">
<CTIcon :symbol="icon" />
</div>

<div class="ct-message__content">
<div v-if="title" class="ct-message__title" v-text="title" />

<div class="ct-message__summary">
<slot />
</div>
</div>
</div>
</template>

<script>
import ThemeMixin from '../mixins/theme'

export default {
mixins: [ThemeMixin],

props: {
title: {
type: String,
default: undefined
},
type: {
type: String,
default: 'information'
}
},

computed: {
icon: ({ type }) => ({
error: 'close-outline',
information: 'information-mark',
warning: 'exclamation-mark-1',
success: 'approve'
}[type] || 'information-mark')
}
}
</script>
27 changes: 27 additions & 0 deletions test/components/Message.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* global cy, describe, it */
import Message from '../../src/components/Message.vue'
// import CTIcon from '../../src/components/Icon.vue'

// Message.components = { CTIcon }

const propsData = {
title: 'The information on this page is currently being updated.',
type: 'information'
}
const slots = {
default: 'Filium morte multavit si sine causa, nollem me tamen laudandis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus vel elit laoreet, dignissim arcu sit amet, vulputate risus.',
}

describe('Organisms/Message', () => {
it('Default', () => {
cy.standardComponentTest(Message, {
mountOptions: {
propsData,
slots
},
options: {
dark: false
}
})
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.