Add styling to comments
This commit is contained in:
parent
b966b4e981
commit
6961c96dd4
|
|
@ -42,11 +42,12 @@ describe('Article page', () => {
|
|||
operations,
|
||||
});
|
||||
|
||||
const commentText = 'First! 🖐️';
|
||||
const commentText = 'First! ';
|
||||
const emoji = '🖐';
|
||||
cy.visit(`/article/${slug}`);
|
||||
cy.getByDataCy('comment-textarea').type(commentText);
|
||||
cy.getByDataCy('emoji-button').should('have.length', 9).first().click();
|
||||
cy.getByDataCy('submit-comment').should('contain', 'Kommentar teilen').click();
|
||||
cy.getByDataCy('comment').first().should('contain', commentText);
|
||||
cy.getByDataCy('comment').first().should('contain', commentText + emoji);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ export default {
|
|||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "@/styles/_variables.scss";
|
||||
@import "@/styles/_functions.scss";
|
||||
@import "@/styles/_mixins.scss";
|
||||
@import "~styles/helpers";
|
||||
|
||||
.news-teaser {
|
||||
position: relative;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@
|
|||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "@/styles/_variables.scss";
|
||||
@import "~styles/helpers";
|
||||
|
||||
$max-width: 100%;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,30 +2,61 @@
|
|||
<div
|
||||
class="comment"
|
||||
data-cy="comment">
|
||||
<div>
|
||||
Author {{ comment.author }}
|
||||
<div class="comment__owner">
|
||||
<user-widget :avatar-url="comment.owner.avatarUrl"/>
|
||||
<span class="comment__owner-name">{{ comment.owner.firstName }} {{ comment.owner.lastName }}</span>
|
||||
</div>
|
||||
<div>
|
||||
Datum {{ comment.created }}
|
||||
<div class="comment__date">
|
||||
{{ comment.created | datetime }}
|
||||
</div>
|
||||
<div>
|
||||
Text {{ comment.text }}
|
||||
<div class="comment__text">
|
||||
{{ comment.text }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserWidget from '@/components/UserWidget';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
comment: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
components: {UserWidget},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '~styles/helpers';
|
||||
|
||||
.comment {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto;
|
||||
grid-template-rows: 2rem auto;
|
||||
grid-template-areas: "o d" "t t";
|
||||
padding: $medium-spacing 0 $large-spacing 0;
|
||||
border-bottom: 1px solid $color-silver;
|
||||
grid-row-gap: $medium-spacing;
|
||||
|
||||
&__owner {
|
||||
grid-area: o;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__date {
|
||||
grid-area: d;
|
||||
justify-self: end;
|
||||
align-self: center;
|
||||
@include regular-text;
|
||||
}
|
||||
|
||||
&__text {
|
||||
grid-area: t;
|
||||
@include regular-paragraph;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<template>
|
||||
<div class="comment-input">
|
||||
<emoji-bar/>
|
||||
<emoji-bar @add-emoji="addEmoji"/>
|
||||
<textarea
|
||||
v-auto-grow
|
||||
:value="value"
|
||||
:value="text"
|
||||
data-cy="comment-textarea"
|
||||
class="comment-input__textarea"
|
||||
placeholder="Kommentar erfassen"
|
||||
|
|
@ -31,12 +31,15 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
text: ''
|
||||
text: this.value
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
updateValue(text) {
|
||||
this.text = text;
|
||||
},
|
||||
addEmoji(emoji) {
|
||||
this.text = this.text + emoji;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<template>
|
||||
<div>
|
||||
<span
|
||||
<div class="emoji-bar">
|
||||
<a
|
||||
:key="index"
|
||||
class="emojis__emoji"
|
||||
class="emoji-bar__emoji"
|
||||
data-cy="emoji-button"
|
||||
v-for="(emoji, index) in emojis"
|
||||
@click="$emit('add-emoji', emoji)">{{ emoji }}</span>
|
||||
@click="$emit('add-emoji', emoji)">{{ emoji }}</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -15,11 +15,27 @@
|
|||
return {
|
||||
emojis: ['🖐️', '👍', '👎', '👏', '👋', '🎉', '😍', '😮', '🤔'],
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '~styles/helpers';
|
||||
|
||||
.emoji-bar {
|
||||
display: flex;
|
||||
border-bottom: 1px solid $color-silver;
|
||||
padding: $small-spacing $medium-spacing;
|
||||
margin: -$medium-spacing;
|
||||
margin-bottom: $medium-spacing;
|
||||
|
||||
&__emoji {
|
||||
font-size: toRem(32px);
|
||||
margin-right: $medium-spacing;
|
||||
display: inline-flex;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -7,3 +7,9 @@ export const dateFilter = value => {
|
|||
return moment(String(value)).format('DD. MMMM YYYY');
|
||||
}
|
||||
};
|
||||
|
||||
export const dateTimeFilter = value => {
|
||||
if (value) {
|
||||
return moment(String(value)).format('DD. MMMM YYYY, hh:mm');
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ mutation AddComment($input: AddCommentInput!) {
|
|||
text
|
||||
id
|
||||
owner {
|
||||
avatarUrl
|
||||
firstName
|
||||
lastName
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ query RoomEntryQuery($slug: String!) {
|
|||
owner {
|
||||
firstName
|
||||
lastName
|
||||
avatarUrl
|
||||
}
|
||||
created
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import VueScrollTo from 'vue-scrollto';
|
|||
import {Validator, install as VeeValidate} from 'vee-validate/dist/vee-validate.minimal.esm.js';
|
||||
import {required, min, decimal, confirmed} from 'vee-validate/dist/rules.esm.js';
|
||||
import veeDe from 'vee-validate/dist/locale/de';
|
||||
import {dateFilter} from './filters/date-filter';
|
||||
import {dateFilter, dateTimeFilter} from './filters/date-filter';
|
||||
import autoGrow from '@/directives/auto-grow';
|
||||
import clickOutside from '@/directives/click-outside';
|
||||
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
||||
|
|
@ -104,6 +104,7 @@ Vue.use(VeeValidate, {
|
|||
});
|
||||
|
||||
Vue.filter('date', dateFilter);
|
||||
Vue.filter('datetime', dateTimeFilter);
|
||||
|
||||
/* guards */
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@
|
|||
|
||||
methods: {
|
||||
createComment(text) {
|
||||
console.log('text', text);
|
||||
this.$apollo.mutate({
|
||||
mutation: ADD_COMMENT_MUTATION,
|
||||
variables: {
|
||||
|
|
@ -93,6 +92,7 @@
|
|||
if (data) {
|
||||
data.roomEntry.comments.edges.unshift({
|
||||
node: comment,
|
||||
__typename: 'CommentNodeEdge'
|
||||
});
|
||||
store.writeQuery({query, variables, data});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
#
|
||||
# Created on 2019-04-09
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.test import RequestFactory, TestCase
|
||||
from graphene.test import Client
|
||||
|
||||
from api.schema import schema
|
||||
from api.utils import get_graphql_query
|
||||
from core.factories import UserFactory
|
||||
|
||||
from users.factories import SchoolClassFactory
|
||||
from users.models import SchoolClassMember
|
||||
|
||||
|
|
@ -43,15 +43,11 @@ class MySchoolClasses(TestCase):
|
|||
node {
|
||||
id
|
||||
name
|
||||
users {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
permissions
|
||||
}
|
||||
}
|
||||
members {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
permissions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +57,7 @@ class MySchoolClasses(TestCase):
|
|||
'''
|
||||
|
||||
result = self.client.execute(query)
|
||||
self.assertIsNone(result.get('errors'))
|
||||
|
||||
classes = result.get('data').get('me').get('schoolClasses').get('edges')
|
||||
self.assertEqual(len(classes), 2)
|
||||
|
|
@ -80,7 +77,3 @@ class MySchoolClasses(TestCase):
|
|||
|
||||
old_classes = result.get('data').get('me').get('oldClasses').get('edges')
|
||||
self.assertEqual(len(old_classes), 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue