Skip to content

Commit 7bd6f4e

Browse files
authored
Merge pull request #118 from laruiss/develop
Develop
2 parents e31c496 + edbc87a commit 7bd6f4e

File tree

8 files changed

+482
-7
lines changed

8 files changed

+482
-7
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { render } from '@testing-library/vue'
2+
3+
import DsfrQuote from './DsfrQuote.vue'
4+
5+
const VIcon = { props: ['name'], template: '<i :class="name"></i>' }
6+
7+
describe('DsfrQuote', () => {
8+
it('should render a complete DsfrQuote', () => {
9+
const quote = 'LA citation'
10+
const author = 'Pierre-Louis EGAUD'
11+
const firstSourceText = 'Détail 1'
12+
const details = [
13+
firstSourceText,
14+
'Détail 2',
15+
'Détail 3',
16+
{
17+
url: 'https://www.wikipedia.fr',
18+
label: 'wikipedia',
19+
},
20+
]
21+
const illustration = 'illustration'
22+
const source = 'Duckduckgo'
23+
const sourceUrl = 'https://www.duckduckgo.com'
24+
const quoteImage = 'https://placekitten.com/g/150/150'
25+
26+
const { container, getByText } = render(DsfrQuote, {
27+
global: {
28+
components: {
29+
VIcon,
30+
},
31+
},
32+
props: {
33+
quote,
34+
author,
35+
details,
36+
illustration,
37+
source,
38+
sourceUrl,
39+
quoteImage,
40+
},
41+
})
42+
const imgEl = container.querySelector('.fr-responsive-img')
43+
const quoteEl = container.querySelector('blockquote p')
44+
const citeEl = getByText(source)
45+
const firstLink = getByText('Détail 1')
46+
const lastLink = container.querySelectorAll('.fr-quote__source li')[details.length]
47+
48+
expect(quoteEl).toBeInTheDocument()
49+
expect(citeEl).toBeInTheDocument()
50+
expect(quoteEl.innerHTML).toContain(quote)
51+
expect(imgEl).toHaveAttribute('src', quoteImage)
52+
expect(firstLink).not.toHaveAttribute('href')
53+
expect(firstLink.innerHTML).toContain(firstSourceText)
54+
expect(lastLink.querySelector('a')).toHaveAttribute('href')
55+
})
56+
})
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import DsfrQuote from './DsfrQuote.vue'
2+
3+
export default {
4+
component: DsfrQuote,
5+
title: 'Basic/Citations',
6+
argTypes: {
7+
dark: {
8+
control: 'boolean',
9+
description: 'Permet de voir le composant dans les deux **thèmes** : **clair** (`false`, défaut) et **sombre* (`true`).\n\n*N.B. : Ne fait pas partie du composant.*',
10+
},
11+
quote: {
12+
control: 'text',
13+
description: '**Texte** de la citation',
14+
},
15+
author: {
16+
control: 'text',
17+
description: '**Auteur** de la citation',
18+
},
19+
details: {
20+
control: 'object',
21+
description: '**Détails** de la citation',
22+
},
23+
illustration: {
24+
control: 'text',
25+
description: '**Illustration** de la citation',
26+
},
27+
separator: {
28+
control: 'text',
29+
description: '**Séparateur** horizontal ou vertical',
30+
},
31+
source: {
32+
control: 'text',
33+
description: '**ouvrage** d\'où est tirée la citation',
34+
},
35+
sourceUrl: {
36+
control: 'text',
37+
description: '**URL** de la source de la citation',
38+
},
39+
quoteImage: {
40+
control: 'text',
41+
description: '**URL** de l\'image',
42+
},
43+
},
44+
}
45+
46+
export const Citation = (args) => ({
47+
components: { DsfrQuote },
48+
data () {
49+
return {
50+
...args,
51+
}
52+
},
53+
template: `
54+
<div :data-rf-theme="dark ? 'dark' : ''" style="background-color: var(--w); padding: 1rem;">
55+
<DsfrQuote
56+
:quote="quote"
57+
:author="author"
58+
:details="details"
59+
:illustration="illustration"
60+
:source="source"
61+
:sourceUrl="sourceUrl"
62+
:quoteImage="quoteImage"
63+
/>
64+
</div>
65+
`,
66+
})
67+
Citation.args = {
68+
dark: false,
69+
quote: 'LA citation',
70+
author: 'Pierre-Louis EGAUD',
71+
separator: '',
72+
details: [
73+
'Détail 1',
74+
'Détail 2',
75+
'Détail 3',
76+
{
77+
url: 'https://www.wikipedia.fr',
78+
label: 'wikipedia',
79+
},
80+
],
81+
illustration: 'illustration',
82+
source: 'Duckduckgo',
83+
sourceUrl: 'https://www.duckduckgo.com',
84+
quoteImage: 'https://placekitten.com/g/150/150',
85+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<template>
2+
<figure class="fr-quote fr-quote--column">
3+
<VIcon
4+
label="Quote"
5+
>
6+
<VIcon
7+
name="ri-chat-1-line"
8+
scale="1.3"
9+
fill="var(--bf500)"
10+
/>
11+
<VIcon
12+
name="ri-double-quotes-l"
13+
scale="0.6"
14+
fill="var(--bf500)"
15+
/>
16+
</VIcon>
17+
18+
<blockquote
19+
v-if="source"
20+
:cite="sourceUrl"
21+
>
22+
<p>« {{ quote }} »</p>
23+
</blockquote>
24+
25+
<figcaption>
26+
<p class="fr-quote__author">
27+
{{ author }}
28+
</p>
29+
30+
<ul class="fr-quote__source">
31+
<li>
32+
<cite>{{ source }}</cite>
33+
</li>
34+
35+
<li
36+
v-for="(detail, index) in details"
37+
:key="index"
38+
>
39+
<a
40+
v-if="typeof detail === 'object'"
41+
target="_blank"
42+
:href="detail.url"
43+
>
44+
{{ detail.label }}
45+
<VIcon
46+
name="ri-external-link-line"
47+
scale="0.9"
48+
/>
49+
</a>
50+
{{ typeof detail !== 'object' ? detail : '' }}
51+
</li>
52+
</ul>
53+
54+
<div class="fr-quote__image">
55+
<img
56+
:src="quoteImage"
57+
class="fr-responsive-img"
58+
alt=""
59+
>
60+
<!-- L’alternative de l’image (attribut alt) doit rester vide car l’image est illustrative et ne doit pas être restituée aux technologies d’assistance -->
61+
</div>
62+
</figcaption>
63+
</figure>
64+
</template>
65+
66+
<script>
67+
export default {
68+
name: 'DsfrQuote',
69+
props: {
70+
quote: {
71+
type: String,
72+
default: undefined,
73+
},
74+
icon: {
75+
type: String,
76+
default: undefined,
77+
},
78+
author: {
79+
type: String,
80+
default: undefined,
81+
},
82+
details: {
83+
type: Array,
84+
default: () => [],
85+
},
86+
illustration: {
87+
type: String,
88+
default: undefined,
89+
},
90+
separator: {
91+
type: String,
92+
default: 'horizontal',
93+
},
94+
source: {
95+
type: String,
96+
default: '',
97+
},
98+
sourceUrl: {
99+
type: String,
100+
default: '',
101+
},
102+
quoteImage: {
103+
type: String,
104+
default: '',
105+
},
106+
},
107+
108+
}
109+
</script>
110+
111+
<style src="./quotes.css" />
112+
113+
<style scoped>
114+
.fr-quote {
115+
color: var(--g800);
116+
}
117+
118+
.fr-quote::before {
119+
content: normal;
120+
}
121+
122+
.fr-quote__source a {
123+
box-shadow: none;
124+
}
125+
.fr-quote__source a::after {
126+
content: normal;
127+
}
128+
</style>

0 commit comments

Comments
 (0)