-
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 #709 from Financial-Times/ENTST-425-create-x-dash-…
…release-branch X-Gift article highlights sharing Release
- Loading branch information
Showing
17 changed files
with
383 additions
and
22 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
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,23 @@ | ||
import { h } from '@financial-times/x-engine' | ||
|
||
export default ({ includeHighlightsHandler, includeHighlights, isGiftUrlCreated }) => { | ||
return ( | ||
<div className="o-forms-input o-forms-input--checkbox o-forms-field x-gift-article__checkbox"> | ||
<label htmlFor="includeHighlights"> | ||
<input | ||
type="checkbox" | ||
id="includeHighlights" | ||
name="includeHighlights" | ||
value={includeHighlights} | ||
checked={includeHighlights} | ||
onChange={includeHighlightsHandler} | ||
disabled={isGiftUrlCreated} | ||
data-trackable="make-highlights-visible" | ||
/> | ||
<span className="o-forms-input__label x-gift-article__checkbox-span"> | ||
Make highlights visible to recipients | ||
</span> | ||
</label> | ||
</div> | ||
) | ||
} |
28 changes: 28 additions & 0 deletions
28
components/x-gift-article/src/HighlightRecipientMessage.jsx
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,28 @@ | ||
import { h } from '@financial-times/x-engine' | ||
|
||
export default ({ handleSaveAnnotations, handleCloseRecipientMessage }) => { | ||
return ( | ||
<div className="x-gift-article-highlight-recipient-message"> | ||
<p className="x-gift-article-highlight-recipient-message__title">Share the highlighted article</p> | ||
<div className="x-gift-article-highlight-recipient-message__divider"></div> | ||
<p className="o-typography-professional o-typography-inverse x-gift-article-highlight-recipient-message__description"> | ||
If you wish to share the highlighted article,{' '} | ||
<button | ||
type="button" | ||
className="o-typography-link x-gift-article-highlight-recipient-message__save-highlights-button" | ||
onClick={handleSaveAnnotations} | ||
> | ||
save the highlights | ||
</button>{' '} | ||
as your own before creating the link. | ||
</p> | ||
<button | ||
className="x-gift-article-highlight-recipient-message__close" | ||
type="button" | ||
onClick={handleCloseRecipientMessage} | ||
> | ||
<span className="o-normalise-visually-hidden">Close</span> | ||
</button> | ||
</div> | ||
) | ||
} |
56 changes: 56 additions & 0 deletions
56
components/x-gift-article/src/HighlightRecipientMessage.scss
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,56 @@ | ||
@import '@financial-times/o-colors/main'; | ||
@import '@financial-times/o-spacing/main'; | ||
@import '@financial-times/o-typography/main'; | ||
|
||
@include oTypography(); | ||
|
||
.x-gift-article-highlight-recipient-message { | ||
position: relative; | ||
background-color: oColorsByName('slate'); | ||
color: oColorsMix('ft-grey', 'white', 20); | ||
padding: oSpacingByName('s3'); | ||
|
||
.x-gift-article-highlight-recipient-message__title { | ||
@include oTypographySans($scale: 1, $weight: 'regular'); | ||
margin: 0; | ||
color: oColorsByName('white'); | ||
} | ||
|
||
.x-gift-article-highlight-recipient-message__description { | ||
@include oTypographySans($scale: 0); | ||
margin: 0; | ||
} | ||
|
||
.x-gift-article-highlight-recipient-message__divider { | ||
padding-top: oSpacingByName('s2'); | ||
padding-bottom: oSpacingByName('s3'); | ||
&::after { | ||
border-top: oSpacingByName('s1') solid oColorsByName('mint'); | ||
content: ''; | ||
position: absolute; | ||
width: 40px; | ||
display: block; | ||
} | ||
} | ||
|
||
.x-gift-article-highlight-recipient-message__close { | ||
background-image: url('https://www.ft.com/__origami/service/image/v2/images/raw/fticon-v1%3Across?source=editor&tint=%23FFFFFF&bgcolor=%23FFFFFF'); | ||
background-repeat: no-repeat; | ||
background-size: contain; | ||
background-position: 50%; | ||
background-color: transparent; | ||
width: oSpacingByName('s6'); | ||
height: oSpacingByName('s6'); | ||
border: none; | ||
padding: 0; | ||
position: absolute; | ||
right: oSpacingByName('s2'); | ||
top: oSpacingByName('s2'); | ||
} | ||
|
||
.x-gift-article-highlight-recipient-message__save-highlights-button { | ||
background: none; | ||
border: none; | ||
padding: 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,21 @@ | ||
import { h } from '@financial-times/x-engine' | ||
|
||
export default ({ handleCloseSuccessMessage }) => { | ||
return ( | ||
<div | ||
className="o-message o-message--alert o-message--success x-gift-article__highlights-saved-message" | ||
data-o-component="o-message" | ||
> | ||
<div className="o-message__container"> | ||
<div className="o-message__content"> | ||
<p className="o-message__content-main"> | ||
<span className="o-message__content-highlight">Highlights saved.</span> | ||
</p> | ||
<button type="button" className="o-message__close" onClick={handleCloseSuccessMessage}> | ||
<span className="o-normalise-visually-hidden">Close</span> | ||
</button> | ||
</div> | ||
</div> | ||
</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,3 @@ | ||
.x-gift-article__highlights-saved-message { | ||
margin-bottom: oSpacingByName('s4'); | ||
} |
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,69 @@ | ||
import { h } from '@financial-times/x-engine' | ||
import { ShareType } from './lib/constants' | ||
import HighlightRecipientMessage from './HighlightRecipientMessage' | ||
import HighlightSavedMessage from './HighlightSavedMessage' | ||
import HighlightCheckbox from './HighlightCheckbox' | ||
import HighlightsApiClient from './lib/highlightsApi' | ||
|
||
const USER_ANNOTATIONS_API = `https://enterprise-user-annotations-api.ft.com/v1` | ||
|
||
export default ({ | ||
shareType, | ||
includeHighlights, | ||
includeHighlightsHandler, | ||
isGiftUrlCreated, | ||
hasHighlights, | ||
saveHighlightsHandler, | ||
showHighlightsRecipientMessage, | ||
showHighlightsSuccessMessage, | ||
showHighlightsCheckbox, | ||
closeHighlightsSuccessMessage, | ||
closeHighlightsRecipientMessage | ||
}) => { | ||
const handleSaveAnnotations = async () => { | ||
const url = new URL(location.href) | ||
const params = new URLSearchParams(url.search) | ||
const highlightsToken = params.get('highlights') | ||
const highlightsAPIClient = new HighlightsApiClient(USER_ANNOTATIONS_API) | ||
const response = await highlightsAPIClient.copySharedHighlights(highlightsToken) | ||
|
||
if (response) { | ||
saveHighlightsHandler() | ||
params.delete('highlights') | ||
url.search = params.toString() | ||
localStorage.setItem('showSuccessSavedMessage', 'true') | ||
location.href = url.toString() | ||
} | ||
} | ||
|
||
if (shareType === ShareType.enterprise && hasHighlights) { | ||
if (isGiftUrlCreated && includeHighlights) { | ||
return ( | ||
<div className="x-gift-article__highlight-section"> | ||
<div className="x-gift-article__highlight-shared">highlights visible to recipients</div> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div className="x-gift-article__highlight-section"> | ||
{showHighlightsRecipientMessage ? ( | ||
<HighlightRecipientMessage | ||
handleSaveAnnotations={handleSaveAnnotations} | ||
handleCloseRecipientMessage={closeHighlightsRecipientMessage} | ||
/> | ||
) : null} | ||
{showHighlightsSuccessMessage ? ( | ||
<HighlightSavedMessage handleCloseSuccessMessage={closeHighlightsSuccessMessage} /> | ||
) : null} | ||
{showHighlightsCheckbox ? ( | ||
<HighlightCheckbox | ||
includeHighlights={includeHighlights} | ||
includeHighlightsHandler={includeHighlightsHandler} | ||
isGiftUrlCreated={isGiftUrlCreated} | ||
/> | ||
) : null} | ||
</div> | ||
) | ||
} | ||
return null | ||
} |
Oops, something went wrong.