mirror of
https://github.com/flarum/core.git
synced 2025-10-14 00:15:51 +02:00
Rewrite Button to Typescript (#2984)
* Rename Button file * Convert to TS * Add debug warning helper Fires `console.warn`, but only when the forum is in debug mode. Can help to inform extension developers of possible issues with their JS code. * Simplify button content template * Rewrite Button component - Prefer `aria-label` over `title` - Don't duplicate button content to `title` attribute - Warn in debug mode if button has no accessible content - Use modern JS/TS syntax (`||=`, spread, etc) * Update to work with new Button component * Update warning Co-authored-by: Matt Kilgore <tankerkiller125@gmail.com> * Fire warning in `oncreate` * Format * Make Button have extensible Attributes type via generics * Update args type * Update js/src/common/components/Button.tsx Co-authored-by: Matt Kilgore <tankerkiller125@gmail.com> Co-authored-by: David Sevilla Martin <me@datitisev.me> Co-authored-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
This commit is contained in:
16
js/src/common/helpers/fireDebugWarning.ts
Normal file
16
js/src/common/helpers/fireDebugWarning.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Calls `console.warn` with the provided arguments, but only if the forum is in debug mode.
|
||||
*
|
||||
* This function is intended to provide warnings to extension developers about issues with
|
||||
* their extensions that may not be easily noticed when testing, such as accessibility
|
||||
* issues.
|
||||
*
|
||||
* These warnings should be hidden on production forums to ensure webmasters are not
|
||||
* inundated with do-gooders telling them they have an issue when it isn't something they
|
||||
* can fix.
|
||||
*/
|
||||
export default function fireDebugWarning(...args: Parameters<typeof console.warn>): void {
|
||||
if (!app.forum.attribute('debug')) return;
|
||||
|
||||
console.warn(...args);
|
||||
}
|
Reference in New Issue
Block a user