From a101ad5de24335c6a565af086aeeb49bd683d736 Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Thu, 12 Dec 2024 16:24:08 +0800 Subject: [PATCH 01/10] add link to profile page in dropdown menu --- src/components/dropdown-card/dropdown-card.js | 12 +++++++++++- src/components/dropdown-icon/dropdown-icon.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/dropdown-card/dropdown-card.js b/src/components/dropdown-card/dropdown-card.js index a091fede6..24fed0dd6 100644 --- a/src/components/dropdown-card/dropdown-card.js +++ b/src/components/dropdown-card/dropdown-card.js @@ -1,9 +1,10 @@ import React from 'react'; +import { navigate } from 'gatsby'; import PropTypes from 'prop-types'; import { useAuth0 } from '@auth0/auth0-react'; import GitHubIcon from '-!svg-react-loader!../../images/github.svg'; -const DropdownCard = () => { +const DropdownCard = ({ setOpen }) => { const { logout, user } = useAuth0(); return ( <> @@ -19,6 +20,15 @@ const DropdownCard = () => {
+ + + ) : ( + '' + )} + + +
+
+

+ + Read more + +

+
+
+ +
+ + ); + })} + + + )} + + ); +}; + +RuleList.propTypes = { + rules: PropTypes.array.isRequired, + viewStyle: PropTypes.string.isRequired, + type: PropTypes.string.isRequired, + onRemoveClick: PropTypes.func.isRequired, + state: PropTypes.number, +}; + +export default ProfileContent; diff --git a/src/components/profile-filter-menu/profile-filter-menu.js b/src/components/profile-filter-menu/profile-filter-menu.js new file mode 100644 index 000000000..11ca25feb --- /dev/null +++ b/src/components/profile-filter-menu/profile-filter-menu.js @@ -0,0 +1,52 @@ +import BookmarkIcon from '-!svg-react-loader!../../images/bookmarkIcon.svg'; +import PropTypes from 'prop-types'; +import React from 'react'; + +const ProfileFilterMenu = ({ + selectedFilter, + setSelectedFilter, + bookmarkedRulesCount, +}) => { + return ( + <> +
+ +
+ + ); +}; + +ProfileFilterMenu.propTypes = { + selectedFilter: PropTypes.number.isRequired, + setSelectedFilter: PropTypes.func.isRequired, + bookmarkedRulesCount: PropTypes.number, +}; + +export const Filter = { + Bookmarks: 0, +}; +export default ProfileFilterMenu; diff --git a/src/pages/profile.js b/src/pages/profile.js new file mode 100644 index 000000000..681f74ead --- /dev/null +++ b/src/pages/profile.js @@ -0,0 +1,106 @@ +import GitHubIcon from '-!svg-react-loader!../images/github.svg'; +import { useAuth0 } from '@auth0/auth0-react'; +import { graphql, useStaticQuery } from 'gatsby'; +import PropTypes from 'prop-types'; +import React, { useState } from 'react'; +import Breadcrumb from '../components/breadcrumb/breadcrumb'; +import ProfileBadge from '../components/profile-badge/profile-badge'; +import ProfileContent from '../components/profile-content/profile-content'; +import ProfileFilterMenu from '../components/profile-filter-menu/profile-filter-menu'; + +const Profile = ({ data }) => { + const [selectedFilter, setSelectedFilter] = useState(0); + const [state, setState] = useState(0); + const [bookmarkedRulesCount, setBookmarkedRulesCount] = useState(); + const { user, isAuthenticated } = useAuth0(); + + if (isAuthenticated) { + return ( + <> + +
+
+
+
+
+ +
+
+ {isAuthenticated ? user.name : ''} +
+ + + GitHub account + +
+ +
+
+ +
+
+
+ + ); + } else { + return ( +

+ Please first login to view profile +

+ ); + } +}; +Profile.propTypes = { + data: PropTypes.object.isRequired, +}; + +function ProfileWithQuery(props) { + const data = useStaticQuery(graphql` + query ProfilePageQuery { + allMarkdownRemark(filter: { frontmatter: { type: { eq: "rule" } } }) { + nodes { + excerpt(format: HTML, pruneLength: 500) + frontmatter { + title + uri + guid + authors { + title + } + } + htmlAst + } + } + } + `); + + return ; +} + +ProfilePage.propTypes = { + props: PropTypes.any, +}; + +export default function ProfilePage({ props }) { + return ( + <> + + + ); +} From 350c7d88be6af2b1a0ad08e475f1776bd1bfb39c Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Thu, 12 Dec 2024 18:06:09 +0800 Subject: [PATCH 04/10] added styles --- src/style.css | 145 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 1 deletion(-) diff --git a/src/style.css b/src/style.css index 88909b5c1..879a66573 100644 --- a/src/style.css +++ b/src/style.css @@ -1426,6 +1426,26 @@ div.bad-example { margin: 0.15rem 0.2rem 0 0; } +.dropdown-user-btn-container:before { + content: "\f007"; + font-family: FontAwesome; + font-size: 1.5rem !important; + margin: 0rem 1rem; +} + +.dropdown-user-btn-container { + color: #666666; + display: flex; + align-items: center; + margin-left: 0; + margin-bottom: 0.5rem; + font-size: 0.9rem; +} + +.dropdown-user-btn-container:hover { + @apply text-ssw-red !important; +} + .dropdown-signout-btn-container:before { content: "\f08b"; font-family: FontAwesome; @@ -1471,6 +1491,18 @@ div.bad-example { color: #333333; } +/* Profile Page */ +.no-content-message { + text-align: center; + margin: 2rem auto; +} + +.profile-header { + background-color: #f5f5f5; + padding: 3rem; + height: auto; +} + .profile-container-img:hover { opacity: 0.8; cursor: pointer; @@ -1483,10 +1515,35 @@ div.bad-example { height: 6.25rem; } +.profile-github-icon { + margin: 0.2rem 0.25rem 0 0; +} + +.profile-image { + grid-row-start: 1; + grid-row-end: 3; +} + @media screen and (max-width: 600px) { .rule-content { padding: 1rem; } + .profile-image { + visibility: hidden; + grid-column: 1; + height: 0 + } + .profile-bookmark-icon { + display: none !important; + } + .profile-large-name { + grid-column: 1; + } + .profile-github-icon { + margin: 0.2rem 0 0 0; + height: 1rem; + width: 1.8rem; + } .github-link { grid-column: 1 !important; padding-top: 0.75rem; @@ -1497,10 +1554,15 @@ div.bad-example { justify-items: center; justify-content: center; } + .profile-container-responsive { + justify-items: start; + justify-content: start; + } .rule-content-title { padding: 0 !important; } } + @media screen and (max-width: 1024px) { .radio-button-1 { grid-column: unset !important; @@ -1511,6 +1573,30 @@ div.bad-example { .radio-button-3 { grid-column: unset !important; } + .profile-large-name { + font-size: 1.75rem !important; + } +} + +@media screen and (max-width: 800px) { + .filter-menu { + grid-template-columns: auto !important; + margin-left: auto; + margin-right: auto; + left: 0 !important; + top: 2rem !important; + } + .menu-item { + grid-column: 1 !important; + } + .profile-header { + height: auto; + } +} + +.profile-large-name { + font-size: 1.75rem; + grid-row: 1; } .github-link { @@ -1529,6 +1615,15 @@ div.bad-example { opacity: 0.8; } +.filter-menu { + top: 3rem; + position: relative; + display: grid; + grid-template-columns: auto; + column-gap: 1rem; + justify-content: start; +} + .radio-button-1 { grid-column: 2; } @@ -1539,8 +1634,33 @@ div.bad-example { grid-column: 4; } +.menu-item { + padding: 0 0.5rem 0.5rem; + text-align: center; + position: relative; + display: flex; + margin: auto; + white-space: nowrap; +} + +.menu-item:hover { + padding: 0 0.5rem 0.25rem; + border-bottom: 0.25rem solid #CC4141; + cursor: pointer; +} + +.menu-item:hover .filter-menu-bookmark-icon { + @apply text-ssw-red; +} + +.bookmarks-item:after { + padding-left: 0.5rem; + font-family: FontAwesome; +} + .heading-container { - display: inline-flex; + display: flex; + justify-content: space-between; background: #f5f5f5; border-left: 2px solid #cc4141; width: 100%; @@ -1553,6 +1673,23 @@ div.bad-example { margin: 0.5rem 0.8rem; } +.profile-bookmark-icon { + height: 2rem; + font-size: 1.8rem !important; + margin: auto auto auto 0; +} + +.filter-menu-bookmark-icon, .filter-menu-bookmark-icon-pressed { + margin: auto; + margin-right: -0.5rem; + height: 1rem; + width: 1.8rem; +} + +.filter-menu-bookmark-icon-pressed { + @apply text-ssw-red; +} + .rule-heading-love:after { content: '\f004'; font-family: FontAwesome; @@ -1587,6 +1724,12 @@ div.bad-example { margin-top: 10px; } +.no-tagged-message:before { + font-family: FontAwesome; + content: '\f00d'; + margin-right: 0.5rem; +} + .error-text { @apply text-ssw-red; } From ee203437abfe12c619072a0e4365832266618bb4 Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Fri, 13 Dec 2024 11:45:40 +0800 Subject: [PATCH 05/10] fix eslint error --- src/components/footer/footer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/footer/footer.js b/src/components/footer/footer.js index 4d2fdc404..9fdf9225b 100644 --- a/src/components/footer/footer.js +++ b/src/components/footer/footer.js @@ -1,8 +1,3 @@ -import React from 'react'; -import preval from 'preval.macro'; -import moment from 'moment'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faHeart } from '@fortawesome/free-solid-svg-icons'; import { faFacebook, faInstagram, @@ -11,8 +6,13 @@ import { faTiktok, faYoutube, } from '@fortawesome/free-brands-svg-icons'; -import { pathPrefix } from '../../../site-config'; +import { faHeart } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import moment from 'moment'; +import preval from 'preval.macro'; +import React from 'react'; import GitHubButton from 'react-github-btn'; +import { pathPrefix } from '../../../site-config'; const buildTimestamp = preval`module.exports = new Date().getTime();`; @@ -33,8 +33,8 @@ const Footer = () => { rel="noreferrer" className="action-button-label footer-greybar-link" > - Star us on GitHub - {' '}. + Star us on GitHub. + {' '} Date: Mon, 16 Dec 2024 11:56:13 +0800 Subject: [PATCH 06/10] fix "remove bookmark" and responsive styling --- .../profile-content/profile-content.js | 99 +++++++++---------- src/style.css | 26 +---- 2 files changed, 50 insertions(+), 75 deletions(-) diff --git a/src/components/profile-content/profile-content.js b/src/components/profile-content/profile-content.js index f08250a19..c5a538205 100644 --- a/src/components/profile-content/profile-content.js +++ b/src/components/profile-content/profile-content.js @@ -31,10 +31,7 @@ const ProfileContent = (props) => { async function onRemoveClick(ruleGuid) { const jwt = await fetchIdToken(); - if ( - isAuthenticated && - window.confirm('Are you sure you want to remove this tag?') - ) { + if (isAuthenticated) { if (props.filter == Filter.Bookmarks) { RemoveBookmark({ ruleGuid: ruleGuid, UserId: user.sub }, jwt) .then(() => { @@ -134,7 +131,6 @@ ProfileContent.propTypes = { const RuleList = ({ rules, viewStyle, type, onRemoveClick, state }) => { const linkRef = useRef(); - const iconClass = type.replace(/\s+/g, '-'); const components = { greyBox: GreyBox, }; @@ -158,53 +154,56 @@ const RuleList = ({ rules, viewStyle, type, onRemoveClick, state }) => {
    {rules.map((rule) => { return ( -
  1. -
    -
    -

    - - {rule.title} - -

    - {type == 'bookmark' ? ( - <> - - - ) : ( - '' - )} -
    -
    -
    +
  2. +
    +
    +

    + + {rule.title} + +

    + {type == 'bookmark' ? ( +
    + +
    + ) : ( + '' + )} +
    +
    +
    -
    -

    - - Read more - -

    -
    -
    +
    +

    + + Read + more + +

    +
    +
    - -
    -
  3. + > + +
    +
  4. + ); })}
diff --git a/src/style.css b/src/style.css index 879a66573..a361f2dcb 100644 --- a/src/style.css +++ b/src/style.css @@ -1295,7 +1295,7 @@ div.bad-example { display: flex; } -.rule-buttons .tooltiptext { +.rule-buttons .tooltiptext, .profile-rule-buttons .tooltip .tooltiptext { left: -20px; margin-bottom: 1rem; } @@ -1533,9 +1533,6 @@ div.bad-example { grid-column: 1; height: 0 } - .profile-bookmark-icon { - display: none !important; - } .profile-large-name { grid-column: 1; } @@ -1658,27 +1655,6 @@ div.bad-example { font-family: FontAwesome; } -.heading-container { - display: flex; - justify-content: space-between; - background: #f5f5f5; - border-left: 2px solid #cc4141; - width: 100%; -} - -.heading-container h2 { - padding: 0 0 0 0.7rem; - background: none; - border-left: none; - margin: 0.5rem 0.8rem; -} - -.profile-bookmark-icon { - height: 2rem; - font-size: 1.8rem !important; - margin: auto auto auto 0; -} - .filter-menu-bookmark-icon, .filter-menu-bookmark-icon-pressed { margin: auto; margin-right: -0.5rem; From 0d8621ca300ff7d0e98e18a07351cb56f5dd5cad Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Tue, 17 Dec 2024 10:35:40 +0800 Subject: [PATCH 07/10] delete comment --- src/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/style.css b/src/style.css index a361f2dcb..e673e7d65 100644 --- a/src/style.css +++ b/src/style.css @@ -1491,7 +1491,6 @@ div.bad-example { color: #333333; } -/* Profile Page */ .no-content-message { text-align: center; margin: 2rem auto; From d1951f3408f2b48d846a20f8ce33cd66aa16c1bb Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Wed, 18 Dec 2024 15:39:29 +0800 Subject: [PATCH 08/10] fixed user dropdown style as per feedback --- src/components/dropdown-card/dropdown-card.js | 29 +++++++++---------- src/style.css | 26 ++++++++++++----- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/components/dropdown-card/dropdown-card.js b/src/components/dropdown-card/dropdown-card.js index 24fed0dd6..3223a093a 100644 --- a/src/components/dropdown-card/dropdown-card.js +++ b/src/components/dropdown-card/dropdown-card.js @@ -1,25 +1,23 @@ -import React from 'react'; +import { useAuth0 } from '@auth0/auth0-react'; import { navigate } from 'gatsby'; import PropTypes from 'prop-types'; -import { useAuth0 } from '@auth0/auth0-react'; -import GitHubIcon from '-!svg-react-loader!../../images/github.svg'; +import React from 'react'; const DropdownCard = ({ setOpen }) => { const { logout, user } = useAuth0(); return ( <>
-
-

@{user.nickname}

- - - Manage GitHub Account - -
-
+

@{user.nickname}

+ +