-
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.
Merge pull request #84 from prezly/feature/dev-13006-theme-support-fo…
…r-the-new-node-type [DEV-13006] Feature - Callout & text highlights
- Loading branch information
Showing
8 changed files
with
151 additions
and
4 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
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,44 @@ | ||
@import "styles/variables"; | ||
|
||
.prezly-slate-callout { | ||
margin: $spacing-2 0; | ||
|
||
color: $color-text; | ||
font-weight: 500; | ||
font-size: $font-size-m; | ||
line-height: $line-height; | ||
|
||
display: flex; | ||
flex-direction: row; | ||
|
||
padding: $spacing-3; | ||
gap: $spacing-1-5; | ||
|
||
background: rgba($color-link, 0.08); | ||
border: 1px solid rgba($color-link, 0.6); | ||
border-radius: $spacing-half; | ||
|
||
&[data-icon]::before { | ||
content: attr(data-icon); | ||
display: block; | ||
} | ||
|
||
&--align-left { | ||
text-align: left; | ||
flex-direction: row; | ||
} | ||
|
||
&--align-center { | ||
text-align: center; | ||
flex-direction: column; | ||
} | ||
|
||
&--align-right { | ||
text-align: right; | ||
flex-direction: row-reverse; | ||
} | ||
|
||
> p { | ||
margin: 0; | ||
} | ||
} |
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,61 @@ | ||
import type { Meta, Story } from '@storybook/react'; | ||
|
||
import { StoryNameDecorator } from '../../dev/StoryNameDecorator'; | ||
import { Renderer } from '../../Renderer'; | ||
|
||
export default { | ||
title: 'Elements/Callout', | ||
decorators: [StoryNameDecorator], | ||
} as Meta; | ||
|
||
const TEXT = { | ||
text: 'I love how Prezly has been created by people who really understand the needs of PR professionals. Its features and functionality are just right for our business.', | ||
}; | ||
|
||
export const Callout: Story = () => ( | ||
<Renderer | ||
nodes={[ | ||
{ | ||
type: 'callout', | ||
icon: '💡', | ||
children: [TEXT], | ||
}, | ||
]} | ||
/> | ||
); | ||
|
||
export const CenterAligned: Story = () => ( | ||
<Renderer | ||
nodes={[ | ||
{ | ||
type: 'callout', | ||
icon: '⚠️', | ||
align: 'center', | ||
children: [TEXT], | ||
}, | ||
]} | ||
/> | ||
); | ||
export const RightAligned: Story = () => ( | ||
<Renderer | ||
nodes={[ | ||
{ | ||
type: 'callout', | ||
icon: '❌', | ||
align: 'right', | ||
children: [TEXT], | ||
}, | ||
]} | ||
/> | ||
); | ||
|
||
export const NoIcon: Story = () => ( | ||
<Renderer | ||
nodes={[ | ||
{ | ||
type: 'callout', | ||
children: [TEXT], | ||
}, | ||
]} | ||
/> | ||
); |
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,34 @@ | ||
import { CalloutNode } from '@prezly/story-content-format'; | ||
import classNames from 'classnames'; | ||
import type { HTMLAttributes } from 'react'; | ||
|
||
import { stringifyNode } from '../../lib'; | ||
|
||
import './Callout.scss'; | ||
|
||
interface Props extends HTMLAttributes<HTMLDivElement> { | ||
node: CalloutNode; | ||
} | ||
|
||
export function Callout({ children, className, node, ...props }: Props) { | ||
const isEmpty = stringifyNode(node).trim() === ''; | ||
|
||
if (isEmpty) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
className={classNames('prezly-slate-callout', className, { | ||
'prezly-slate-callout--align-inherit': node.align === undefined, | ||
'prezly-slate-callout--align-left': node.align === CalloutNode.Alignment.LEFT, | ||
'prezly-slate-callout--align-center': node.align === CalloutNode.Alignment.CENTER, | ||
'prezly-slate-callout--align-right': node.align === CalloutNode.Alignment.RIGHT, | ||
})} | ||
data-icon={node.icon || undefined} | ||
{...props} | ||
> | ||
<p>{children}</p> | ||
</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 @@ | ||
export { Callout } from './Callout'; |
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