From 6635292760912df938625afb37272c9f4991cce2 Mon Sep 17 00:00:00 2001
From: Stoyan Delev
+
+ paragraph
+
+ component
+
.emotion-0 {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
- display: -ms-inline-flexbox;
- display: inline-flex;
- max-width: 100%;
+ margin: 0;
+ color: #2E2E2E;
+ font-family: "DM Sans",sans-serif;
+ font-size: 16px;
+ line-height: 1.5;
+ font-weight: 400;
+ letter-spacing: 0;
+}
+
+.emotion-0 svg {
+ fill: #2E2E2E;
}
.emotion-1 {
+ margin: 0 0 0 0.15em;
+ float: left;
+ margin-top: 4px;
+ color: #0A0A0A;
+}
+
+@media screen and (max-width: 767px) {
+ .emotion-1 {
+ font-size: 5.625em;
+ line-height: 0.85;
+ }
+}
+
+@media screen and (min-width: 768px) and (max-width: 1023px) {
+ .emotion-1 {
+ font-size: 5.875em;
+ line-height: 0.85;
+ }
+}
+
+@media screen and (min-width: 1024px) {
+ .emotion-1 {
+ font-size: 6em;
+ line-height: 0.85;
+ }
+}
+
+.emotion-1 svg {
+ fill: #0A0A0A;
+}
+
+.emotion-2 {
+ display: block;
+ clip: rect(0 0 0 0);
+ -webkit-clip-path: inset(100%);
+ clip-path: inset(100%);
+ height: 1px;
+ overflow: hidden;
+ position: absolute;
+ white-space: nowrap;
+ width: 1px;
+}
+
+
+
+ paragraph
+
+ component
+
+ This is paragraph text +
+ + */ export const Paragraph: React.FC +- - paragraph - - component -
+ paragraph component + -- - paragraph - + paragraph component @@ -267,7 +269,7 @@ exports[`Paragraph renders with drop cap and complex children 1`] = ` > link -
+ `; diff --git a/src/typography/paragraph/paragraph.tsx b/src/typography/paragraph/paragraph.tsx index 62f9422edd..6709ab8860 100644 --- a/src/typography/paragraph/paragraph.tsx +++ b/src/typography/paragraph/paragraph.tsx @@ -49,29 +49,29 @@ export const ParagraphDropCap = withOwnTheme(ThemelessParagraphDropCap)({ defaults, }); -const getFirstWord = ( +const getFirstLetter = ( children: (React.ReactChild | React.ReactFragment | React.ReactPortal)[], ): string => { const [firstChild] = children; - if (children.length > 0 && typeof firstChild === 'string') { - return firstChild.split(' ')[0]; + if (typeof firstChild === 'string') { + return firstChild.split('')[0]; } - if (children.length && isFragment(firstChild)) { - return getFirstWord(React.Children.toArray(firstChild.props.children)); + if (isFragment(firstChild)) { + return getFirstLetter(React.Children.toArray(firstChild.props.children)); } return ''; }; -const removeFirstWord = ( +const removeFirstLetter = ( children: (React.ReactChild | React.ReactFragment | React.ReactPortal)[], ): (React.ReactChild | React.ReactFragment | React.ReactPortal)[] => { const [firstChild, ...rest] = children; - if (children.length > 0 && typeof firstChild === 'string') { - return [firstChild.split(' ').slice(1).join(' '), ...rest]; + if (typeof firstChild === 'string') { + return [firstChild.split('').slice(1).join(''), ...rest]; } - if (children.length && isFragment(firstChild)) { + if (isFragment(firstChild)) { return [ - removeFirstWord(React.Children.toArray(firstChild.props.children)), + removeFirstLetter(React.Children.toArray(firstChild.props.children)), ...rest, ]; } @@ -79,41 +79,25 @@ const removeFirstWord = ( return children; }; -/** - -For a11y reason we need to add aria-hidden to the first word of the paragraph. -Creating the fallowing structure: - -- This is paragraph text -
- - */ - export const Paragraph: React.FC -+ This being Black History Month, last week was Politicians + In Search Of An Eye-Catching Race-Related Policy Week. Both Theresa May + and Jeremy Corbyn had their own announcement, each + seemingly benign and right-on, each actually destructive and wrong-headed. + This being Black History Month, last week was + Politicians In Search Of An Eye-Catching Race-Related Policy Week. +
+
Paragraph component containing a subscript element and a{' '}
From a3f8f92da3254dae8089123bb61347ff0c8c39fd Mon Sep 17 00:00:00 2001
From: Stoyan Delev