Skip to content

Feature to share news/posts/articles#162

Merged
medyo merged 8 commits intomedyo:developfrom
idebenone:shareFeature
Nov 22, 2023
Merged

Feature to share news/posts/articles#162
medyo merged 8 commits intomedyo:developfrom
idebenone:shareFeature

Conversation

@idebenone
Copy link
Copy Markdown
Contributor

Added an option to share news on the card.

@medyo medyo linked an issue Sep 5, 2023 that may be closed by this pull request
@medyo medyo added the New feature Request a new language to add label Sep 5, 2023
@medyo
Copy link
Copy Markdown
Owner

medyo commented Sep 11, 2023

@idebenone, could you please include both the title and the URL when sharing content, like this:

it would be helpful if you could show the title before sharing so that users can have some context for what they are sharing.

Thank you

@idebenone
Copy link
Copy Markdown
Contributor Author

Hey @medyo !
I just did a commit with title as well as source of the article also. Please check and let me know.

@medyo
Copy link
Copy Markdown
Owner

medyo commented Sep 14, 2023

@idebenone

  • The UI looks a bit different from other pages, Could you make it like the settings modal (with inputs and buttons), something like the rss section
  • Add a parent class to classes like .link .copy... to prevent potential conflicts with other components in the future
  • Please include the title prop for the share buttons.
  • The passed props to the buttons need optimisation to eliminate redundancy, such as setting the size to 32 and passing the URL as url={data.link}.

@idebenone
Copy link
Copy Markdown
Contributor Author

@medyo
image

new ui of the modal matching the settings modal.
removed the prop redundancy on share buttons
added parent class in css
added title prop for share buttons.

}: CardItemWithActionsProps) => {
const [showModal, setShowModal] = useState(false)
const [link, setLink] = useState({})
const [data, setData] = useState({})
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

data is too generic, please use a name like socialShareData or socialSharePayload

Comment on lines +29 to +37
const sharingButtons = [
{ component: EmailShareButton, icon: FaMailBulk, title: 'Mail' },
{ component: FacebookShareButton, icon: FaFacebookSquare, title: 'Facebook' },
{ component: TwitterShareButton, icon: FaTwitterSquare, title: 'Twitter' },
{ component: RedditShareButton, icon: FaRedditSquare, title: 'Reddit' },
{ component: LinkedinShareButton, icon: FaLinkedinIn, title: 'Linkedin' },
{ component: TelegramShareButton, icon: FaTelegram, title: 'Telegram' },
{ component: WhatsappShareButton, icon: FaWhatsappSquare, title: 'Whatsapp' },
]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please you use colourful icons, they look much better

Comment thread src/features/shareModal/components/ShareModal.tsx Outdated
@medyo medyo changed the base branch from master to develop October 8, 2023 11:13
@medyo
Copy link
Copy Markdown
Owner

medyo commented Oct 8, 2023

@idebenone the source text(LOBSTERS) looks brighter on light mode, please use the right css var, and keep it capitalised.

Thanks
image

@idebenone
Copy link
Copy Markdown
Contributor Author

@medyo
Sorry for the delay and I have updated the css with right variable for source text and capitalized it

@medyo
Copy link
Copy Markdown
Owner

medyo commented Oct 15, 2023

@idebenone I couldn't merge your branch, it has some conflicts with the develop branch, can you take a look?
thanks

@idebenone
Copy link
Copy Markdown
Contributor Author

Hey @medyo
I just resolved the conflicts!
(I swear to god I almost had a heart attack going through it....my first time)

@medyo
Copy link
Copy Markdown
Owner

medyo commented Oct 26, 2023

Hey @medyo I just resolved the conflicts! (I swear to god I almost had a heart attack going through it....my first time)

yeah, conflicts can be really draining, but you'll improve through practice.
I hope you're good.

I've given your code a test run, and it seems that the bookmark icon is no longer displaying.

image

@medyo
Copy link
Copy Markdown
Owner

medyo commented Oct 26, 2023

I think it's a CSS issue, @victor-duarte can you take a look at this?

@idebenone
Copy link
Copy Markdown
Contributor Author

@medyo
Yeah I just noticed....I'll try to see what's the problem

@idebenone
Copy link
Copy Markdown
Contributor Author

idebenone commented Oct 26, 2023

image

.blockActionButton:nth-child(1) {
margin-right: 40px;
}

this will push the margin of bookmark icon from right making it visible on the screen.
Should I go with this or do I give new CSS class for both Block Action Buttons (bookmark & share)?

@medyo
Copy link
Copy Markdown
Owner

medyo commented Oct 26, 2023

I think we need a scalable way to allow adding more than 2 buttons.
What about wrapping these buttons(share, bookmark...) with flexbox and then applying the slide/opacity animation to whole div instead of the button?

@victor-duarte
Copy link
Copy Markdown
Contributor

👋🏻

Note: When enabling tab navigation an odd scroll was displaying when focusing on the CTA due to the container being outside the card and animating into the card. The animation was applied on the button instead and the container moved within the card preventing the layout shift.

My 2 cents would be to go with a simple solution that allows having the 2 buttons and if in the future a third button is needed maybe looking into alternative card designs. I am no designer but maybe something the line X or instagram.

e.g:
image

Suggestion

.blockActionButton {
  ...
  bottom: 40px;
  ...
}

.blockActionButton + .blockActionButton {
  bottom: 8px;
}
...
.blockRow:hover .blockActionButton,
.blockActionButton:focus-visible,
.blockActionButton:focus-visible ~ .blockActionButton, /* OPTIONAL: to improve tab navigation experience (subjective) */
.blockActionButton.active
.blockActionButton.active ~ .blockActionButton /* OPTIONAL: to display share icon when an item is book marked */ {
  ...
}

  • Hover will display the two buttons
  • Tab navigation will display the buttons independently (or partially together if optional line above is added in css). See attachments.
option-1.mov
option-2.mov

Comment thread src/assets/index.css
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
} No newline at end of file
Copy link
Copy Markdown
Contributor

@victor-duarte victor-duarte Oct 27, 2023

Choose a reason for hiding this comment

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

Revert and update touched files.

  • For consistency leave an empty line on the files (might be due to a local config in the IDE that the lines are being stripped out)


{cardItem}
<div className={`blockActions ${isBookmarked ? 'active' : ''} `}>
<button
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add aria-label="Bookmark item".

onClick={onBookmarkClick}>
{!isBookmarked ? <BiBookmarkPlus /> : <BiBookmarkMinus />}
</button>
<button className={`blockActionButton `} onClick={handleOpenModal}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add aria-label="Open share modal"


const handleOpenModal = () => {
setShowModal(!showModal)
setShareData({ title: item.title, link: item.url, source: source })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: avoid the. double state:

  • Use the shareData to handle the modal toggle
    • Reset the data when the modal closes

I don't know much about react best practices but it seems the double state is not needed since the modal depends on if data is selected or not.


.shareBody p {
font-size: 15px;
line-height: 1px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adjust element margins instead of setting line height to 1px

overlayClassName="Overlay">
<div className="modalHeader">
<h1 className="modalTitle">Share</h1>
<button className="modalCloseBtn" onClick={handleCloseModal}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add aria-label="Close share modal"

<h3>{shareData.title}</h3>
<div className="shareLink">
<input type="text" value={shareData.link} disabled />
<button onClick={copyLink}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add aria-label="Copy source url to clipboard"

ariaHideApp={false}
shouldCloseOnEsc={true}
shouldCloseOnOverlayClick={true}
shouldFocusAfterRender={false}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Set this to true to improve a11y

  • Will allow the user to reach the modal if navigating with keyboard and close the modal when hitting ESC
  • Would suggest doing this on other modals also

gap: 20px;
}

@media (max-width: 768px) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: if you follow a mobile first approach you could trim down a couple of lines:

.shareModal {
  background-color: var(--card-background-color);
  bottom: 0;
  box-shadow: 0 0 20px #00000052;
  box-sizing: border-box;
  left: 0;
  padding-bottom: 90px;
  padding: 12px 12px 90px;
  position: absolute;
  width: 100%;
}

...

@media (min-width: 768px) {
  .shareModal {
    border-radius: 10px;
    bottom: auto;
    left: 50%;
    padding-bottom: 12px;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 450px;
  }

  .shareOptions {
    gap: 20px;
  }
}


.shareLink {
display: flex;
flex-direction: row;
Copy link
Copy Markdown
Contributor

@victor-duarte victor-duarte Oct 27, 2023

Choose a reason for hiding this comment

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

flex-row is the default direction, it can be removed.

@victor-duarte
Copy link
Copy Markdown
Contributor

victor-duarte commented Nov 3, 2023

👋🏻 @medyo if permission are granted in this branch/PR I can apply the changes of the comments above.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

cc: @idebenone

@medyo
Copy link
Copy Markdown
Owner

medyo commented Nov 3, 2023

@victor-duarte I don't see any setting to allow that permission on my side.
I think it's up to the PR owner to allow changes on his branch

@victor-duarte
Copy link
Copy Markdown
Contributor

victor-duarte commented Nov 3, 2023

@idebenone, if a hand is needed please let me know if you are able to grant permissions to work on the PR.
Thanks!

@idebenone
Copy link
Copy Markdown
Contributor Author

@idebenone, if a hand is needed please let me know if you are able to grant permissions to work on the PR. Thanks!

Hey @victor-duarte
I'm not able to find the option to allow collaborators on PR. I'll try to fix as many as possible(my hands are quiet tied rn).

@idebenone
Copy link
Copy Markdown
Contributor Author

@victor-duarte

added all the aria-labels and made other css related changes that you had suggested related to shareModal
The modals doesnt close on ESC press even after setting ariaHideApp={true}. Need to look deeper into this.

@idebenone
Copy link
Copy Markdown
Contributor Author

@medyo Could you please review my last commit?

@medyo
Copy link
Copy Markdown
Owner

medyo commented Nov 19, 2023

@idebenone "To address issues with smaller post rows, let's switch the flex direction to 'row' with some gaps, The current implementation isn't fitting well.

image
  • Could you remove the position: absolute from the blockActionButton? We're currently managing the animation at the parent level

@idebenone
Copy link
Copy Markdown
Contributor Author

idebenone commented Nov 20, 2023

image

image

@medyo

position: absolute removed. Pushed margin on left and bottom to give a nice lift to the buttons. Also changed the order of the elements. With bookmark button as the first element from left, if a post is saved it will look odd when the button is active.
If everything is cool, I'll commit the changes.

@medyo
Copy link
Copy Markdown
Owner

medyo commented Nov 20, 2023

Yes, this looks much better. Feel free to commit the new changes

@idebenone
Copy link
Copy Markdown
Contributor Author

@medyo Done 👍.

@medyo
Copy link
Copy Markdown
Owner

medyo commented Nov 22, 2023

Thanks a lot @idebenone, You did great!

@medyo medyo merged commit 1ceae40 into medyo:develop Nov 22, 2023
medyo added a commit that referenced this pull request Dec 9, 2023
* Feature to share news/posts/articles (#162)

* feature to share news/posts/articles

* added title and source to share model

* added title, removed redundancy of props

* colorful icons & title prop added to button

* css updated

* css changes

* fixed block-action-btns

* Merge branch 'shareFeature' of github.com:idebenone/hackertab.dev

* fix yarn.lock

* persist fetched queries in localstorage

* improve the share modal UI

* track copy and share events

* tag hackertabdev twitter account

* add missing api url

---------

Co-authored-by: Vineeth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New feature Request a new language to add

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to share articles/posts/news link on social media

3 participants