-
Notifications
You must be signed in to change notification settings - Fork 133
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 the announcement component #2472
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2472 +/- ##
==========================================
- Coverage 50.98% 50.97% -0.02%
==========================================
Files 124 125 +1
Lines 5305 5307 +2
Branches 1137 1137
==========================================
Hits 2705 2705
- Misses 2311 2313 +2
Partials 289 289 ☔ View full report in Codecov by Sentry. |
@damithc, could we get your opinion on whether component is needed? |
@Tim-Siu thanks for taking this on. @yucheng11122017 thx for checking. I quite like the placement/behavior I have in https://nus-cs2103-ay2021s1.github.io/website/ I prefer that to a toast that appears in front of other content and forces the user to dismiss it. |
Sure. I will make the announcement component behave like that. |
I am thinking of adding a minimise button next to the dismiss button, the only difference is by clicking the minimise button, the user can always re-click it (somewhere) to make the announcement appear again. |
dismiss() { | ||
this.dismissed = true; | ||
}, | ||
setPosition() { |
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.
Since there are some repeating codes (width and height), would it be better to refactor setPosition()
in this way:
// create a map
const placementStyles = {
"top": {
top: '20px',
left: '50%',
transform: 'translateX(-50%)'
},
"top-right": {
top: '20px',
right: '20px'
},
"top-left": {
top: '20px',
left: '20px'
},
"bottom": {
bottom: '20px',
left: '50%',
transform: 'translateX(-50%)'
},
"bottom-right": {
bottom: '20px',
right: '20px'
},
"bottom-left": {
bottom: '20px',
left: '20px'
}
}
setPosition() {
const announcementElement = this.$refs.announcement;
if (!announcementElement) return;
const { width, height } = announcementElement.getBoundingClientRect();
// get the respective styles from the map
const positionStyle = { ...placementStyles[this.placement] };
// since only width and height are specified in these cases
if (this.placement.endsWith('right') || this.placement.endsWith('left')) {
positionStyle.width = `${width}px`;
positionStyle.height = `${height}px`;
}
this.positionStyle = positionStyle;
}
By doing this, next time if we introduce a new placement (eg. middle-left), we can just add the corresponding style to the map.
Hi can you add documentation so its easier to test? And also add test cases for this. |
cb84513
to
69ec838
Compare
After discussions with Prof. Demith, it appears that extending Box components to support announcements will be a better approach. |
What is the purpose of this pull request?
Overview of changes:
Contribute to #2241
Related to #1960
This Pull request adds a announcement component. One usecase of the annoucement can be seen in the CS2103/T website.
Sample usage:
Output:
Screen.Recording.2024-03-24.at.17.30.12.mov
Parameters:
dismissible
: 'true', 'false;placement
: 'top', 'top-right', 'top-left', 'bottom', 'bottom-right', 'bottom-left',theme
: 'primary', 'secondary', 'success', 'warning', 'danger', 'info', 'light', 'dark',Anything you'd like to highlight/discuss:
Discussions:
There are a lot of options we can add to this component.
Known limitations:
Testing instructions:
Proposed commit message: (wrap lines at 72 characters)
Add an announcement component
Checklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major
,r.Minor
,r.Patch
.Breaking change release note preparation (if applicable):