-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from danskernesdigitalebibliotek/DDFFORM-5-ar…
…tikler-brodtekst Rich text / WYSIWYG styling. DDFFORM-5.
- Loading branch information
Showing
7 changed files
with
176 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
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,20 @@ | ||
import { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
import { withDesign } from "storybook-addon-designs"; | ||
import { RichText } from "./RichText"; | ||
|
||
export default { | ||
title: "Library / Rich Text", | ||
component: RichText, | ||
decorators: [withDesign], | ||
parameters: { | ||
design: { | ||
type: "figma", | ||
url: "https://www.figma.com/file/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?type=design&node-id=7880-59101&mode=design&t=dMcJmvsouH6erxzA-4", | ||
}, | ||
layout: "centered", | ||
}, | ||
} as ComponentMeta<typeof RichText>; | ||
|
||
const Template: ComponentStory<typeof RichText> = () => <RichText />; | ||
|
||
export const Default = Template.bind({}); |
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 @@ | ||
export interface RichTextProps { | ||
text: string; | ||
} | ||
|
||
export const RichText = () => { | ||
return ( | ||
<div className="rich-text"> | ||
<h2>Tad survive ensnare joy mistake courtesy Bagshot Row.</h2> | ||
<p> | ||
<a href="#">Ligulas step drops both?</a> You shall not pass! Tender | ||
Tender respectable success. Valar impressive unfriendly bloom scraped? | ||
Branch hey-diddle-diddle <strong>pony troublell sleeping</strong>. | ||
</p> | ||
<h3>North valor overflowing sort Iáve mister kingly money?</h3> | ||
<p> | ||
Curse you and all the halflings! Deserted anytime Lake-town burned caves | ||
balls. Smoked lthilien forbids Thrain? | ||
</p> | ||
<ul> | ||
<li>Adamant.</li> | ||
<li> | ||
Ligulas step drops <em>both? You shall not pass!</em>. Valar | ||
impressive unfriendly bloom scraped? Branch hey-diddle-diddle pony | ||
troublell sleeping during jump Narsil. | ||
</li> | ||
<li>Witch-king.</li> | ||
<li>Precious.</li> | ||
<li>Gaffers!</li> | ||
</ul> | ||
<h3> | ||
Narsil enjoying shattered bigger leaderless retrieve dreamed dwarf. | ||
</h3> | ||
<p> | ||
Ravens wonder wanted runs me crawl gaining lots faster! Khazad-dum | ||
surprise baby season ranks. I bid you all a very fond farewell. | ||
</p> | ||
<ol> | ||
<li>Narsil.</li> | ||
<li>Elros.</li> | ||
<li>Arwen Evenstar.</li> | ||
<li> | ||
Ligulas step drops both? You shall not pass! Tender respectable | ||
success Valar impressive unfriendly bloom scraped? Branch | ||
hey-diddle-diddle pony troublell sleeping during jump Narsil. | ||
</li> | ||
<li>Bagginses?</li> | ||
</ol> | ||
</div> | ||
); | ||
}; |
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,77 @@ | ||
// This component is used for WYSIWYG content. | ||
// E.g. we cannot control classes of the underlying elements, so in this case | ||
// we will target HTML tags instead. | ||
.rich-text { | ||
@include typography($typo__rich-text-body); | ||
|
||
// Setting a max-width to increase readability for sentences. | ||
max-width: $layout__max-width--text; | ||
|
||
a { | ||
@extend %text-inline-link; | ||
} | ||
|
||
h2 { | ||
@include typography($typo__h3); | ||
} | ||
|
||
h3 { | ||
@include typography($typo__h4); | ||
} | ||
|
||
> * { | ||
margin-bottom: $s-md; | ||
} | ||
|
||
ol > li, | ||
ul > li { | ||
$_dash-width: 21px; | ||
$_dash-width--wide: 33px; | ||
|
||
position: relative; | ||
padding-left: $_dash-width + $s-md; | ||
padding-bottom: $s-lg; | ||
|
||
&::before { | ||
position: absolute; | ||
top: 0.8em; | ||
left: 0; | ||
width: $_dash-width; | ||
text-align: center; | ||
} | ||
|
||
@include media-query__medium { | ||
padding-left: $_dash-width--wide + $s-lg; | ||
|
||
&::before { | ||
width: $_dash-width--wide; | ||
} | ||
} | ||
} | ||
|
||
ul > li::before { | ||
content: ""; | ||
height: 1px; | ||
background-color: black; | ||
} | ||
|
||
ol { | ||
counter-reset: list; | ||
|
||
> li::before { | ||
@include typography( | ||
$typo__h4, | ||
( | ||
excludes: ( | ||
line-height, | ||
), | ||
) | ||
); | ||
|
||
font-weight: normal; | ||
line-height: 0; | ||
counter-increment: list; | ||
content: counter(list) "."; | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
$layout__max-width: 1024px; | ||
$layout__max-width--small: 768px; | ||
$layout__max-width--large: 1440px; | ||
|
||
$layout__max-width--text: 780px; |
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