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

Add news announcement carousel to dashboard #9617

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

cl8n
Copy link
Member

@cl8n cl8n commented Dec 9, 2022

changes from the design on figma:

  • no rounded corners, because rest of this page doesn't have them either
  • height is slightly different, because the news post previews also have a thinner layout than on figma
  • added the markdown overlay

i wasn't sure how it was supposed to animate so I made it slide horizontal. if you aren't interacting with it, it'll automatically rotate every 6 seconds (arbitrary), and otherwise you can control it yourself with the buttons on the side

news_announcements is also intended to be the lazer version of stable's main menu banners, but for now no endpoint or anything.

resolves #9614

* @property string $url
* @method static Builder default()
*/
class NewsAnnouncement extends Model
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not always about News. And may not even about Announcement.

Copy link
Member

Choose a reason for hiding this comment

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

i recommend something in the vein of "highlights" as per the original designs

Copy link
Member Author

Choose a reason for hiding this comment

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

"Highlight" sounds fine to me but it's kind of a generic word, just in this project it's already used a lot regarding search or styling
DashboardHighlight? Headline? MainMenuBanner? idk what to call this thing lol

Copy link
Collaborator

Choose a reason for hiding this comment

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

just Banner is probably fine

resources/views/home/user.blade.php Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
return (
<div className={`${bn}__indicators`}>
{this.props.announcements.map((_, index) => (
<div
Copy link
Collaborator

Choose a reason for hiding this comment

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

these should probably be clickable

Copy link
Member Author

Choose a reason for hiding this comment

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

they're so small (6px max height) that it's kind of annoying to try to click them. I can't tell from the design if they were intended to be buttons...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's too bad as long the button expands on hover

Copy link
Member Author

Choose a reason for hiding this comment

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

added -- I was thinking that if the button still feels too thin, the hoverable/clickable height could be increased while keeping the display as-is. but I'll wait for your input

resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
app/Models/NewsAnnouncement.php Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
resources/assets/lib/news-announcements/main.tsx Outdated Show resolved Hide resolved
@nanaya
Copy link
Collaborator

nanaya commented Jan 4, 2023

I just remembered, should this be shared with in-client banner system? The actual image will be different but I imagine there should be some overlaps in the content itself (if not exactly the same).

@Walavouchey
Copy link
Member

the client banner can only display one at a time (but i do believe i've heard they can be set to automatically rotate) while this website carousel can display multiple. the intention with the linked issue was that they would have the same type of content, yes (and as mentioned in op, eventually displayed in lazer too)

@nanaya
Copy link
Collaborator

nanaya commented Jan 6, 2023

So the client banner currently isn't stored anywhere. The new table here should add client_image_url so bancho can be updated to use it as well.

@cl8n
Copy link
Member Author

cl8n commented Aug 9, 2023

okay, a lot of updates here. the main react component is basically rewritten now to use only CSS for the positions and animations, which resolved a lot of your reviews just by being able to get rid of all that ref/observer/etc stuff (ee2dd65)

I also made it support that "infinite scrolling" feel since it wasn't actually very difficult after rewriting it (tl;dr clone the announcements as needed to make it appear as if you can scroll to one side forever; delete unnecessary clones when it stops animating) (dfd92c8)

I just remembered, should this be shared with in-client banner system? The actual image will be different but I imagine there should be some overlaps in the content itself (if not exactly the same).

yep that's the goal as mentioned in OP, it should be able to work for web, stable, and also lazer whenever it gets a similar feature. just website for this PR though. once this PR is in, I'll get in touch w/ ephemeral or whoever is managing the main menu banners currently, to figure out how this system could be shared best

Comment on lines +21 to +26
$table->text('content_markdown')->nullable();
$table->timestamp('ended_at')->nullable();
$table->string('image_url');
$table->tinyInteger('order');
$table->timestamp('started_at')->useCurrent();
$table->string('url');
Copy link
Collaborator

@nanaya nanaya Aug 15, 2023

Choose a reason for hiding this comment

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

this ended up rather weird when viewed from a db client. At least the start/end time should be close together

* @property string $url
* @method static Builder default()
*/
class NewsAnnouncement extends Model
Copy link
Collaborator

Choose a reason for hiding this comment

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

just Banner is probably fine

import * as React from 'react';
import { classWithModifiers } from 'utils/css';

function modulo(dividend: number, divisor: number): number {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is more like positiveModulo

Comment on lines +21 to +24
height: 100%;
left: 50%;
position: absolute;
transform: translateX(-50%);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This way probably handles fitting in the box better (including when the image is too wide)

height: 100%;
width: 100%;
object-fit: contain; // or cover

Comment on lines +51 to +60
height: 250px; // news-announcements__container height
justify-content: center;
margin-top: 20px; // news-announcements margin

&--with-indicators {
// This part won't be identical to the real component if the indicators
// wrap onto more than one line, but it's good enough for a placeholder
margin-bottom:
10px /* news-announcements__indicators margin */ +
6px /* news-announcements__indicator height */;
Copy link
Collaborator

Choose a reason for hiding this comment

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

put the dimensions in variable maybe (or use the actual classes directly instead of copying style)

this.minIndex = 0;
};

private renderAnnouncement = (announcement: NewsAnnouncementJson, index = 0) => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks like could be its own component

);
}

private clearAutoRotateTimer = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

class methods should be readonly

.news-announcement {
height: 100%;
left: calc(100% * var(--index, 0));
overflow-x: hidden;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's this for? Doesn't the news-announcements__container already cover the overflow hiding?

Comment on lines +76 to +79
{/*
Render the announcements, including clones before and after to help
create the illusion of an infinitely scrolling container
*/}
Copy link
Collaborator

@nanaya nanaya Aug 25, 2023

Choose a reason for hiding this comment

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

where's the clone? the range below only generates exactly the length of announcements.

From what I can tell the illusion currently happens because the clone is generated exactly before the animation starts?

(oh and unless you go furious with clicking, index - 2, index + 3 range also works)

@nanaya
Copy link
Collaborator

nanaya commented May 8, 2024

@cl8n still interested in finishing this? In addition to the comments above, the data source should be changed to use this json file instead (env configurable). Can be either downloaded server side and rendered accordingly or done completely on front end.

@cl8n
Copy link
Member Author

cl8n commented May 20, 2024

@nanaya there was some discussion about this that amounted to nobody being sure if this should share the same data as the in-game banners, because those often link to news on the front page, and it would be kind of redundant. ppy/osu#27680 (comment) (and then more on discord but there was no real conclusion)

personally I don't find sharing data to be problematic as long as whoever controls it is mindful about not literally duplicating content from news banners. but whoever those ppl are should probably be the ones deciding how this works

I'll respond to the previous review in the meantime

@nanaya
Copy link
Collaborator

nanaya commented May 20, 2024

if there's something that's really redundant (current top news post, and no other rotating banner) then can add flag indicating such in the json maybe.

Even duplicating is probably not as much problem as it's two different sections (current highlight vs news post listing). And if there's a new news post coming the older news post banner can still be the highlight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Home page "highlights" section
4 participants