forked from dnum-mi/vue-dsfr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ Implémente le composant "Mise en exergue"
- Loading branch information
1 parent
2ce8dc9
commit baf9287
Showing
5 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { render } from '@testing-library/vue' | ||
|
||
import DsfrHighlight from './DsfrHighlight.vue' | ||
|
||
describe('DsfrHighlight', () => { | ||
it('should display a highlighted text medium', () => { | ||
const text = 'Texte de la mise en exergue' | ||
|
||
const { getByText } = render(DsfrHighlight, { | ||
props: { | ||
text, | ||
}, | ||
}) | ||
|
||
const pEl = getByText(text) | ||
|
||
expect(pEl.parentNode).toHaveClass('fr-highlight') | ||
expect(pEl).not.toHaveClass('fr-text--sm') | ||
expect(pEl).not.toHaveClass('fr-text--lg') | ||
}) | ||
|
||
it('should display a highlighted text medium if large and small are provided as props', () => { | ||
const text = 'Texte de la mise en exergue' | ||
|
||
const { getByText } = render(DsfrHighlight, { | ||
props: { | ||
text, | ||
small: true, | ||
large: true, | ||
}, | ||
}) | ||
|
||
const pEl = getByText(text) | ||
|
||
expect(pEl.parentNode).toHaveClass('fr-highlight') | ||
expect(pEl).not.toHaveClass('fr-text--sm') | ||
expect(pEl).not.toHaveClass('fr-text--lg') | ||
}) | ||
|
||
it('should display a highlighted text small if small is provided as props', () => { | ||
const text = 'Texte de la mise en exergue' | ||
|
||
const { getByText } = render(DsfrHighlight, { | ||
props: { | ||
text, | ||
small: true, | ||
}, | ||
}) | ||
|
||
const pEl = getByText(text) | ||
|
||
expect(pEl.parentNode).toHaveClass('fr-highlight') | ||
expect(pEl).toHaveClass('fr-text--sm') | ||
expect(pEl).not.toHaveClass('fr-text--lg') | ||
}) | ||
|
||
it('should display a highlighted text large if large is provided as props', () => { | ||
const text = 'Texte de la mise en exergue' | ||
|
||
const { getByText } = render(DsfrHighlight, { | ||
props: { | ||
text, | ||
large: true, | ||
}, | ||
}) | ||
|
||
const pEl = getByText(text) | ||
|
||
expect(pEl.parentNode).toHaveClass('fr-highlight') | ||
expect(pEl).not.toHaveClass('fr-text--sm') | ||
expect(pEl).toHaveClass('fr-text--lg') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import DsfrHighlight from './DsfrHighlight.vue' | ||
|
||
export default { | ||
component: DsfrHighlight, | ||
title: 'Éléments/Mise en Exergue - Highlight', | ||
argTypes: { | ||
dark: { | ||
control: 'boolean', | ||
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.*', | ||
}, | ||
text: { | ||
control: 'text', | ||
description: 'Texte de la mise en avant', | ||
}, | ||
small: { | ||
control: 'boolean', | ||
description: 'Permet d’afficher le texte en petit', | ||
}, | ||
large: { | ||
control: 'boolean', | ||
description: 'Permet d’afficher le texte en plus grand', | ||
}, | ||
}, | ||
} | ||
|
||
export const MiseEnExergue = (args) => ({ | ||
components: { | ||
DsfrHighlight, | ||
}, | ||
|
||
data () { | ||
return { ...args } | ||
}, | ||
|
||
template: ` | ||
<div :data-rf-theme="dark ? 'dark' : ''" style="background-color: var(--w);"> | ||
<DsfrHighlight | ||
:text="text" | ||
:small="small" | ||
:large="large" | ||
/> | ||
</div> | ||
`, | ||
}) | ||
|
||
MiseEnExergue.args = { | ||
small: false, | ||
large: false, | ||
text: 'Texte original de la mise en exergue', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script> | ||
export default { | ||
name: 'DsfrHighlight', | ||
props: { | ||
text: { | ||
type: String, | ||
default: undefined, | ||
}, | ||
small: Boolean, | ||
large: Boolean, | ||
}, | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="fr-highlight"> | ||
<p | ||
:class="{ | ||
'fr-text--lg': large && !small, | ||
'fr-text--sm': small && !large, | ||
}" | ||
> | ||
{{ text }} | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<style src="./highlights.css"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
/* ------------------------------------ *\ | ||
HIGHLIGHTS | ||
\* ------------------------------------ */ | ||
|
||
.fr-highlight { | ||
padding-left: 1rem; | ||
font-size: 1rem; | ||
line-height: 1.5rem; | ||
} | ||
|
||
.fr-highlight p { | ||
margin-bottom: 0; | ||
} | ||
|
||
.fr-highlight { | ||
border-left: 0.25rem solid var(--bf500); | ||
} | ||
|
||
@media (min-width: 48em) { | ||
.fr-highlight { | ||
padding-left: 2rem; | ||
margin-left: 2rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters