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

Merged
merged 48 commits into from
Oct 7, 2024

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

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

resolves #9614

app/Models/NewsAnnouncement.php Outdated Show resolved Hide resolved
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

app/Models/NewsAnnouncement.php Outdated Show resolved Hide resolved
resources/js/components/news-announcements.tsx Outdated Show resolved Hide resolved
resources/css/bem/news-announcement.less Outdated Show resolved Hide resolved
resources/css/bem/user-home.less Outdated Show resolved Hide resolved
resources/js/components/news-announcements.tsx Outdated Show resolved Hide resolved
resources/js/components/news-announcements.tsx Outdated Show resolved Hide resolved
resources/css/bem/news-announcement.less Outdated Show resolved Hide resolved
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)

Copy link
Member Author

Choose a reason for hiding this comment

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

hopefully clarified this explanation

for simplification to index - 2, index + 3 or something similar -- i mean it's pretty straightforward to track min/max index so i think this is fine as-is, even if it only practically improves an edge case

@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

@RockRoller01
Copy link
Contributor

That new design looks quite bad for the caroussel, main menu banners are not really designed to float in the middle of an area

@Walavouchey
Copy link
Member

Walavouchey commented Jun 18, 2024

Walavouchey — 09/05/2024 09:10
note that most menu banners are cut at the bottom, i.e. can't really float centred like that

edo/flyte — 09/05/2024 09:16
Moving forward, the future banners should be floating design.

most of the recent banners would only require minor adjustments if any at all

nanaya
nanaya previously requested changes Jun 24, 2024

.menu-image {
height: 100%;
left: calc(100% * var(--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.

the variable should be defined otherwise it may end up using unrelated variable from its parents

&::before {
.fas();
content: var(--icon);
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems fine with default text shadow

Comment on lines 16 to 19
<div
className={bn}
style={{ '--index': index } as React.CSSProperties}
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this div can just be the anchor instead?

};

private readonly handleIndicatorClick = (event: React.MouseEvent<HTMLButtonElement>) => {
// Increment the index by the visible difference between the selected and
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it even possible to trigger this when the index is outside normal range... (as opposed to just setIndex(dataset.index))

Comment on lines 27 to 28
@observable private maxIndex = this.length - 1;
@observable private minIndex = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

these can just be getters?

  private get maxIndex() {
    return Math.max(this.length - 1, this.index);
  }

  private get minIndex() {
    return Math.min(0, this.index);
  }

...or maybe even inlined at the only place they're used, although that'd be a bit long

$images = self::parse(self::fetch());
$now = Carbon::now();

return array_values(array_filter($images, function ($image) use ($now) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can use fn ($image) => ...

overflow-x: hidden;
position: relative;

&__arrow {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe only show this when hovering the area

@nanaya
Copy link
Collaborator

nanaya commented Oct 2, 2024

@cl8n any plan to update this? Otherwise I can do it instead.

@cl8n
Copy link
Member Author

cl8n commented Oct 2, 2024

not soon so yeah you can take it over if it's a priority

The linter doesn't quite render less variable access right so rework it
for now.
app/Http/Controllers/HomeController.php Outdated Show resolved Hide resolved
config/osu.php Outdated Show resolved Hide resolved
resources/js/components/menu-images.tsx Show resolved Hide resolved
resources/views/home/user.blade.php Outdated Show resolved Hide resolved
@notbakaneko
Copy link
Collaborator

Is this missing a push 🤔

@nanaya
Copy link
Collaborator

nanaya commented Oct 7, 2024

if only I pushed it to the correct repository/branch 👀

@notbakaneko notbakaneko merged commit 702d218 into ppy:master Oct 7, 2024
3 checks passed
@peppy peppy self-requested a review October 8, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Home page "highlights" section
5 participants