-
Notifications
You must be signed in to change notification settings - Fork 379
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
base: master
Are you sure you want to change the base?
Conversation
* @property string $url | ||
* @method static Builder default() | ||
*/ | ||
class NewsAnnouncement extends Model |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
return ( | ||
<div className={`${bn}__indicators`}> | ||
{this.props.announcements.map((_, index) => ( | ||
<div |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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). |
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) |
So the client banner currently isn't stored anywhere. The new table here should add |
Hide overflow on the top element rather than the announcements container, so now the container can be transformed by CSS rather than scrolled through. And clean up many other things that resulted from not needing to track element widths and such.
And add transition to height
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)
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 |
So it won't be confusing naming when there are multiple kinds of buttons
$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'); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
height: 100%; | ||
left: 50%; | ||
position: absolute; | ||
transform: translateX(-50%); |
There was a problem hiding this comment.
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
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 */; |
There was a problem hiding this comment.
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) => ( |
There was a problem hiding this comment.
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 = () => { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
{/* | ||
Render the announcements, including clones before and after to help | ||
create the illusion of an infinitely scrolling container | ||
*/} |
There was a problem hiding this comment.
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 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 |
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. |
changes from the design 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
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