Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [UEPR-187] [UEPR-192] [UEPR-194] ToU modal display logic #9248

Open
wants to merge 59 commits into
base: ux-integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8fbe282
fix(deps): lock file maintenance
renovate[bot] Feb 9, 2025
b45a5a4
Merge pull request #9215 from scratchfoundation/renovate/lock-file-ma…
renovate[bot] Feb 10, 2025
2c0d0ff
fix(deps): update dependency scratch-l10n to v5.0.120
renovate[bot] Feb 10, 2025
1938b3d
Merge pull request #9217 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 10, 2025
dc7e1dd
fix(deps): lock file maintenance
renovate[bot] Feb 10, 2025
59f427f
fix(deps): update dependency scratch-l10n to v5.0.121
renovate[bot] Feb 11, 2025
ffe73db
Merge pull request #9218 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 11, 2025
06b83e1
chore(deps): update babel monorepo to v7.26.8
renovate[bot] Feb 11, 2025
a28dd3a
Merge pull request #9219 from scratchfoundation/renovate/babel-monorepo
renovate[bot] Feb 11, 2025
758b921
fix(deps): update dependency scratch-l10n to v5.0.122
renovate[bot] Feb 12, 2025
79e21e6
Merge pull request #9222 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 12, 2025
6e02ed0
fix(deps): update dependency scratch-l10n to v5.0.123
renovate[bot] Feb 12, 2025
d6c5187
Merge pull request #9223 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 12, 2025
ce07895
fix(deps): update dependency scratch-storage to ^4.0.49
renovate[bot] Feb 12, 2025
7c8e26c
Merge pull request #9224 from scratchfoundation/renovate/scratch-stor…
renovate[bot] Feb 12, 2025
d9da016
chore(deps): update formatjs monorepo
renovate[bot] Feb 12, 2025
2253cd7
Merge pull request #9225 from scratchfoundation/renovate/formatjs-mon…
renovate[bot] Feb 12, 2025
9fc12c0
fix(deps): update dependency scratch-l10n to v5.0.124
renovate[bot] Feb 13, 2025
cd23d05
Merge pull request #9226 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 13, 2025
a6eb8c9
Merge pull request #9227 from scratchfoundation/renovate/lock-file-ma…
renovate[bot] Feb 13, 2025
f030ba3
fix(deps): lock file maintenance
renovate[bot] Feb 13, 2025
bb6a14d
chore(deps): update dependency postcss to v8.5.2
renovate[bot] Feb 13, 2025
6f019b4
Merge pull request #9228 from scratchfoundation/renovate/postcss-8.x
renovate[bot] Feb 14, 2025
5884f2c
fix(deps): update dependency scratch-l10n to v5.0.127
renovate[bot] Feb 14, 2025
74dc0b1
Merge pull request #9229 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 14, 2025
61cfb3a
Merge pull request #9230 from scratchfoundation/renovate/lock-file-ma…
renovate[bot] Feb 15, 2025
6015df0
fix(deps): update dependency scratch-l10n to v5.0.128
renovate[bot] Feb 15, 2025
ce5c661
Merge pull request #9231 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 15, 2025
40219f2
fix(deps): update dependency scratch-storage to ^4.0.50
renovate[bot] Feb 15, 2025
42149da
Merge pull request #9232 from scratchfoundation/renovate/scratch-stor…
renovate[bot] Feb 15, 2025
a4d5374
fix(deps): update dependency scratch-l10n to v5.0.129
renovate[bot] Feb 16, 2025
9496e23
Merge pull request #9233 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 16, 2025
b51d0a5
chore(deps): update dependency webpack to v5.98.0
renovate[bot] Feb 16, 2025
b9174aa
Merge pull request #9234 from scratchfoundation/renovate/webpack-5.x
renovate[bot] Feb 17, 2025
0df8fbf
fix(deps): update dependency scratch-l10n to v5.0.130
renovate[bot] Feb 17, 2025
6830a4e
Merge pull request #9235 from scratchfoundation/renovate/scratch-l10n…
renovate[bot] Feb 17, 2025
4a5a03d
chore(deps): update dependency sass to v1.85.0
renovate[bot] Feb 17, 2025
7873f8f
Merge pull request #9236 from scratchfoundation/renovate/sass-1.x
renovate[bot] Feb 17, 2025
9c32066
Merge pull request #9240 from scratchfoundation/ux-integration
MiroslavDionisiev Feb 17, 2025
f6939f1
fix(deps): update dependency scratch-storage to ^4.0.52
renovate[bot] Feb 17, 2025
49ae1aa
Merge pull request #9238 from scratchfoundation/renovate/scratch-stor…
renovate[bot] Feb 17, 2025
dd0c497
chore(deps): update babel monorepo to v7.26.9
renovate[bot] Feb 17, 2025
390c0f5
Merge pull request #9239 from scratchfoundation/renovate/babel-monorepo
renovate[bot] Feb 17, 2025
6728662
feat: [UEPR-192] Added modal structure
Bogomil-Stoyanov Feb 18, 2025
2d52682
feat: [UEPR-192] changes to the modal logic
Bogomil-Stoyanov Feb 19, 2025
2d2913b
feat: [UEPR-192] Name changes and changes in logic
Bogomil-Stoyanov Feb 19, 2025
afaa1ce
feat: [UEPR-192] Adding UI to Iver 16 and under 16 modals
Bogomil-Stoyanov Feb 20, 2025
3b8428c
feat: [UEPR-192] Reminder modals
Bogomil-Stoyanov Feb 20, 2025
ba05413
feat: [UEPR-192][UEPR-194] Changes to modals, added ToU banner
Bogomil-Stoyanov Feb 21, 2025
235e1b1
feat: [UEPR-192][UEPR-194] Do not show modals on specific pages, bann…
Bogomil-Stoyanov Feb 21, 2025
1b6b152
feat: [UEPR-187] [UEPR-194] Changes to reminder modal
Bogomil-Stoyanov Feb 24, 2025
a1d19f6
feat: [UEPR-187] [UEPR-192] [UEPR-194] renaming tos to tou, fixes clo…
Bogomil-Stoyanov Feb 24, 2025
9eb948c
feat: [UEPR-192] removed required from props and removed unused flag
Bogomil-Stoyanov Feb 24, 2025
c5bf924
feat: [UEPR-187] [UEPR-192] [UEPR-194] renaming, reordering component…
Bogomil-Stoyanov Feb 24, 2025
e23a67e
feat: [UEPR-187] [UEPR-192] [UEPR-194] renaming string res, moving co…
Bogomil-Stoyanov Feb 25, 2025
3aab2ee
feat: [UEPR-187] [UEPR-192] Locked account modal
Bogomil-Stoyanov Feb 25, 2025
e6a2c9b
feat: [UEPR-187] [UEPR-192] Typo and removed export
Bogomil-Stoyanov Feb 25, 2025
3af2345
feat: [UEPR-187] [UEPR-192] [UEPR-194] Moved color and changed file n…
Bogomil-Stoyanov Feb 25, 2025
cf28d6b
feat: [UEPR-192] fixed typo
Bogomil-Stoyanov Feb 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
503 changes: 272 additions & 231 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@
"react-twitter-embed": "3.0.3",
"react-use": "17.6.0",
"scratch-parser": "6.0.0",
"scratch-storage": "^4.0.47"
"scratch-storage": "^4.0.52"
},
"devDependencies": {
"@babel/cli": "7.26.4",
"@babel/core": "7.26.7",
"@babel/eslint-parser": "7.26.5",
"@babel/core": "7.26.9",
"@babel/eslint-parser": "7.26.8",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-transform-async-to-generator": "7.25.9",
"@babel/plugin-transform-object-rest-spread": "7.25.9",
"@babel/preset-env": "7.26.7",
"@babel/preset-env": "7.26.9",
"@babel/preset-react": "7.26.3",
"@formatjs/intl-datetimeformat": "6.17.2",
"@formatjs/intl-datetimeformat": "6.17.3",
"@formatjs/intl-locale": "3.4.6",
"@formatjs/intl-numberformat": "8.15.2",
"@formatjs/intl-pluralrules": "5.4.2",
"@formatjs/intl-relativetimeformat": "11.4.9",
"@formatjs/intl-numberformat": "8.15.3",
"@formatjs/intl-pluralrules": "5.4.3",
"@formatjs/intl-relativetimeformat": "11.4.10",
"@scratch/scratch-gui": "^11.0.0-beta.2",
"@types/jest": "29.5.14",
"async": "3.2.6",
Expand Down Expand Up @@ -124,7 +124,7 @@
"minilog": "2.1.0",
"pako": "0.2.8",
"plotly.js": "1.47.4",
"postcss": "8.5.1",
"postcss": "8.5.2",
"postcss-import": "12.0.1",
"postcss-loader": "4.3.0",
"postcss-simple-vars": "5.0.2",
Expand All @@ -145,17 +145,17 @@
"redux-mock-store": "1.5.5",
"redux-thunk": "2.4.2",
"regenerator-runtime": "0.13.9",
"sass": "1.84.0",
"sass": "1.85.0",
"sass-loader": "10.5.2",
"scratch-l10n": "5.0.119",
"scratch-l10n": "5.0.130",
"selenium-webdriver": "4.28.1",
"slick-carousel": "1.8.1",
"stream-browserify": "3.0.0",
"style-loader": "4.0.0",
"tap": "14.11.0",
"url-loader": "3.0.0",
"use-onclickoutside": "0.4.1",
"webpack": "5.97.1",
"webpack": "5.98.0",
"webpack-bundle-analyzer": "4.10.2",
"webpack-cli": "5.1.4",
"webpack-dev-middleware": "5.3.4",
Expand Down
39 changes: 39 additions & 0 deletions src/components/modal/terms-of-use/over16/modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import {injectIntl, FormattedMessage} from 'react-intl';
import Modal from '../../base/modal.jsx';
import {TermsOfUseLink} from '../terms-of-use-modal.jsx';
import Button from '../../../forms/button.jsx';

const TermsOfUseModalOver16 = () => (
<Modal
overlayClassName="tou-modal-overlay"
className="tou-modal"
showCloseButton={false}
isOpen
>
<div className="tou-modal-top" />
<div className="tou-modal-content">
<h1 className="tou-modal-heading">
<FormattedMessage id="tos.updatedTerms" />
</h1>
<p>
<FormattedMessage
id="tos.over16.updatedTermsNotice"
values={{
a: TermsOfUseLink
}}
/>
</p>
<p>
<FormattedMessage id="tos.over16.acceptConfirmation" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tos -> termsOfUse

generally it's better to avoid abbreviations where possible, as that tends to confuse readers not familiar with that part of the code

</p>
<div className="tou-modal-button-container">
<Button className="tou-modal-button filled">
<FormattedMessage id="tos.over16.acceptContinue" />
</Button>
</div>
</div>
</Modal>
);

export default injectIntl(TermsOfUseModalOver16);
46 changes: 46 additions & 0 deletions src/components/modal/terms-of-use/terms-of-use-banner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, {useCallback, useState} from 'react';
import {injectIntl, FormattedMessage} from 'react-intl';
import TermsOfUseReminderModal from './under16/terms-of-use-reminder.jsx';

Copy link
Contributor

@KManolov3 KManolov3 Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, following this file hierarchy, there is no need to include terms-of-use in the naming of the file themselves as that is already qualified by the route. It is still good to include it in the naming of the component function

require('./terms-of-use-modal.scss');

const TermsOfUseLink = chunks => {
const [isModalVisible, setIsModalVisible] = useState(false);
const handleOpenModal = useCallback(() => {
setIsModalVisible(true);
}, []);

const handleCloseModal = useCallback(() => {
setIsModalVisible(false);
}, []);

return (
<>
<a
className="tou-banner-link"
onClick={handleOpenModal}
>
{chunks}
</a>
<TermsOfUseReminderModal
onClose={handleCloseModal}
isOpen={isModalVisible}
/>
</>
);

};

const TermsOfUseBanner = () => (
<div className="tou-banner">
<FormattedMessage
id="tos.banner.parentAgreement"
values={{
a: TermsOfUseLink
}}
/>
</div>
);


export default injectIntl(TermsOfUseBanner);
71 changes: 71 additions & 0 deletions src/components/modal/terms-of-use/terms-of-use-modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React, {useCallback, useState} from 'react';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import TermsOfUseModalOver16 from './over16/modal.jsx';
import TermsOfUseModalUnder16 from './under16/modal.jsx';

require('./terms-of-use-modal.scss');

export const noShowTermsOfUseModalPages = ['terms_of_use', 'privacy_policy', 'dmca', 'cookies'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this const to the page component, where it is used



export const TermsOfUseLink = chunks => (
<a
className="tou-modal-link"
target="_blank"
href="terms_of_use"
>
{chunks}
</a>
);

const TermsOfUseModal = ({
hasAgreedToLatestTermsOfService,
isInTermsOfUseGracePeriod,
isAfterTermsOfUseGracePeriod,
usesParentEmail,
email
}) => {
const [isModalVisible, setIsModalVisible] = useState(true);
const handleClose = useCallback(() => {
setIsModalVisible(false);
});

if (hasAgreedToLatestTermsOfService ?? true) {
return null;
}

if (usesParentEmail) {
if (!isInTermsOfUseGracePeriod && !isAfterTermsOfUseGracePeriod) {
return (<TermsOfUseModalUnder16
email={email}
isOpen={isModalVisible}
onClose={handleClose}
/>);
}
if (isAfterTermsOfUseGracePeriod){
return null; // TODO
}
return null;
}

return <TermsOfUseModalOver16 />;
};

TermsOfUseModal.propTypes = {
hasAgreedToLatestTermsOfService: PropTypes.bool,
isInTermsOfUseGracePeriod: PropTypes.bool,
isAfterTermsOfUseGracePeriod: PropTypes.bool,
usesParentEmail: PropTypes.bool,
email: PropTypes.string
};

const mapStateToProps = state => ({
hasAgreedToLatestTermsOfService: state.session.session.flags?.has_accepted_terms_of_use,
isInTermsOfUseGracePeriod: state.session.session.flags?.is_in_terms_of_use_grace_period,
isAfterTermsOfUseGracePeriod: state.session.session.flags?.is_after_terms_of_use_grace_period,
usesParentEmail: state.session.session.flags?.with_parent_email,
email: state.session.session.user?.email
});

export default connect(mapStateToProps)(TermsOfUseModal);
99 changes: 99 additions & 0 deletions src/components/modal/terms-of-use/terms-of-use-modal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
@import "../../../colors";
@import "../../../frameless";

.tou-modal-overlay {
background-color: transparentize($overlay-gray, 0.2);
}

.tou-modal-top{
height: 48px;
background-color: $ui-mint-green;
border-top-left-radius: 1rem;
border-top-right-radius: 1rem;
}

.tou-modal{
width: 464px;
}

.tou-modal-content{
padding: 2rem;
box-sizing: border-box;
}

.tou-modal-heading{
font-size: 24px;
}
.tou-modal-button {
border-radius: 0.3rem;
padding: 0.5rem 1rem;
border-color: transparent;
font-size: 16px;
font-weight: 600;
}

.tou-modal-button.filled {
background-color: $ui-mint-green;
color: $ui-white;
}

.tou-modal-button.outlined {
background-color: $ui-white;
color: $ui-mint-green;
border: 1px solid $ui-mint-green;
}

.tou-modal-button-container {
display: flex;
justify-content: flex-end;
margin-top: 16px;
gap: 8px;
}

.tou-modal-button:hover {
background-color: hsl(163, 85%, 35%);
color: $ui-white;
}

.tou-modal-link {
color: $ui-mint-green !important;
text-decoration: underline !important;
}

.tou-input {
width: calc(100% - 10px);
padding: 10px 5px;
margin: 5px 0;
font-size: 14px;
color: $type-dark-gray;
background-color: white;
border: 1px solid $active-dark-gray;
border-radius: 6px;
outline: none;
transition: border 0.2s ease-in-out;
font-weight: 600;
}

.tou-center-content{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}

.tou-banner{
height: 50px;
background-color: $ui-red-dark;
font-size: 16px;
font-weight: 700;
color: white;
display: flex;
justify-content: center;
align-items: center;
}

.tou-banner-link{
text-decoration: underline !important;
color: white !important;
}
Loading
Loading