Repository navigation
feat(html5/plugin): add support for custom svg for actions bar buttons - #22923
Conversation
… button set by plugin
|
""" WalkthroughThe changes in this pull request refactor the Sequence Diagram(s)sequenceDiagram
participant A as ActionsBar
participant P as Plugin
participant B as Button
A->>A: Initialize buttonProps object
alt plugin.icon contains iconName
A->>A: Set icon using plugin.icon
else
A->>A: Set icon using custom icon
end
A->>B: Pass buttonProps (via spread operator)
""" 📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (13)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx (1)
55-63: Custom SVG icon support works well but could be improvedThe conditional logic for handling custom SVG icons is implemented correctly. However, consider these improvements:
- Add a fallback for when both
plugin.iconandplugin.customIconSvgare null- Using an
<i>tag for SVG content is unusual - consider using a more semantic wrapper or no wrapperif (plugin.icon === null) { + if (plugin.customIconSvg) { buttonProps.customIcon = ( - <i> + <span className="custom-icon"> {plugin.customIconSvg} - </i> + </span> ); + } else { + // Fallback to a default icon or handle the case + buttonProps.icon = 'warning'; + } } else { buttonProps.icon = plugin.icon; }Does the Button component properly handle SVG content wrapped in an
<i>tag? If there are styling concerns, a more appropriate wrapper might be needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx (1)
bigbluebutton-html5/imports/ui/components/presentation/styles.js (1)
Button(172-190)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: build-package (others)
- GitHub Check: build-package (bbb-html5)
- GitHub Check: build-package (bbb-graphql-server)
- GitHub Check: build-package (bbb-playback-record)
🔇 Additional comments (2)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx (2)
43-43: Good refactoring of button properties!Consolidating the button properties into a
buttonPropsobject improves code readability and maintainability. This approach makes the code more organized and easier to understand.Also applies to: 46-54
66-68: Clean JSX with spread operatorUsing the spread operator to pass the properties to the Button component makes the JSX cleaner and more maintainable. Good choice!
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx (1)
58-62: Consider using semantic markup for SVG iconsUsing an
<i>tag as a container for SVG content is not semantically correct. For better accessibility and semantics, consider using a more appropriate element like<span>with an appropriate ARIA role if needed.buttonProps.customIcon = ( - <i> + <span className="custom-svg-icon"> {plugin.icon.svgContent} - </i> + </span> );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx (1)
bigbluebutton-html5/imports/ui/components/presentation/styles.js (1)
Button(172-190)
🪛 Biome (1.9.4)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx
[error] 55-55: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 57-57: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: build-package (others)
- GitHub Check: build-package (bbb-html5)
- GitHub Check: build-package (bbb-graphql-server)
- GitHub Check: build-package (bbb-playback-record)
🔇 Additional comments (3)
bigbluebutton-html5/imports/ui/components/actions-bar/component.jsx (3)
43-43: Good refactoring to improve code organizationConsolidating button properties into a
buttonPropsobject makes the code more maintainable and easier to read. This is a positive change that follows good React practices and makes future modifications simpler.Also applies to: 46-54
66-68: Good use of the spread operator for propsUsing the spread operator to pass the properties to the Button component is a clean approach that improves code readability.
46-63:Details
❓ Verification inconclusive
Verify custom SVG rendering behavior
The implementation successfully adds support for custom SVG icons as requested in the PR objectives. However, it's important to verify that SVG content renders properly in all supported browsers.
🌐 Web query:
Are there any browser compatibility issues with inline SVG content in React applications?💡 Result:
Inline SVG content in React applications generally works well across modern browsers, but there are several compatibility considerations and potential issues to be aware of:
Core Compatibility
- Modern browsers (Chrome, Firefox, Safari, Edge) fully support inline SVG rendering in React when using standard practices[1][4][7].
- Internet Explorer 11 requires polyfills for
fetchAPI andNumber.isNaNwhen using libraries likereact-inlinesvg[1][10].Common Issues
Attribute Handling
- React requires camelCased SVG attributes (e.g.,
strokeWidthinstead ofstroke-width)[6][9]- Deprecated
xlink:hrefshould be replaced withhrefwith proper namespace declarations[5][9]Styling Limitations
// Incorrect in some browsers <svg style="fill: red"> // Correct React syntax <svg style={{ fill: 'red' }}>Style objects must use React's syntax to avoid rendering issues[7][9].
CORS Restrictions
Remote SVGs require proper CORS headers, particularly when modifying SVG content dynamically[1][4].Namespace Issues
Missing XML namespaces can break SVG rendering:// Problematic in older browsers <svg> <use href="#icon" /> // Recommended <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <use xlinkHref="#icon" /> </svg> ```[5][6][9]Optimization & Fallbacks
- Polyfills: Required for IE11 support (
fetch,Promise,Number.isNaN)[1][10]- Performance: Complex SVGs may require optimization with tools like SVGO[7][9]
- Fallback strategies:
<ReactSVG src="icon.svg"> <img src="fallback.png" alt="Fallback" /> </ReactSVG> ```[1][7]Mobile Browser Considerations
Some mobile browsers have limited support for:
- SVG filters and blend modes[7][9]
- SMIL animations[4][9]
viewBoxscaling calculations[5][7]Developers should test extensively using tools like BrowserStack and implement feature detection where critical SVG functionality is required[7][9]. Using popular React SVG libraries like
react-inlinesvgor@svgr/webpackhelps abstract many compatibility concerns while providing caching and error handling[1][4][7].Citations:
- 1: https://www.npmjs.com/package/react-inlinesvg
- 2: react/react#17645
- 3: react/create-react-app#1388
- 4: https://blog.logrocket.com/how-to-use-svgs-react/
- 5: https://css-tricks.com/6-common-svg-fails-and-how-to-fix-them/
- 6: https://www.useanvil.com/blog/engineering/eslint-plugin-svg-jsx/
- 7: https://refine.dev/blog/react-svg/
- 8: https://dev.to/michaliskout/handling-svg-icons-in-react-2cpb
- 9: https://www.contentful.com/blog/svg-react-import-images/
- 10: https://www.npmjs.com/package/react-inlinesvg/v/3.0.1
Custom SVG Rendering Verification – Please Ensure Cross-Browser Testing
The new implementation for custom SVG icons appears sound: when a plugin provides an SVG via its
svgContent, it is wrapped and passed through as a custom icon. Based on current information, inline SVG content in React renders well in modern browsers (Chrome, Firefox, Safari, Edge). However, note the following:
Legacy Browser Support: If your application requires support for older browsers (e.g., Internet Explorer 11), additional testing is needed. IE11 may require polyfills (for features like
fetchorNumber.isNaN) and careful attention to SVG attribute naming (i.e., using camelCased properties in React).Testing Recommendations:
- Verify that the SVG markup provided in
plugin.icon.svgContentis well-formed and renders correctly across all target browsers.- Confirm that using an
<i>tag as a container does not interfere with the SVG’s accessibility or style. Consider whether a more semantically appropriate container (or directly rendering the<svg>element) is warranted based on your app’s design.Overall, if your target browsers are primarily modern ones, this implementation should work as expected; otherwise, please double-check compatibility with legacy browsers.
🧰 Tools
🪛 Biome (1.9.4)
[error] 55-55: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 57-57: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
ramonlsouza
left a comment
There was a problem hiding this comment.
please check coderabbit comment about potential TypeError with optional chaining
…n adding a new icon to the actions bar button
|
Automated tests Summary✅ All the CI tests have passed! |



What does this PR do?
It adds support for a custom svg icon on an actions bar button.
Motivation
Add more flexibility for the plugin developer to choose an icon for that area. It can be extended for other areas as well in further PRs.
How to test:
I'd recommend to use the sample plugin
sample-actions-bar-plugin. Or just add the following snippet to your own plugin:More
Closely related to PR bigbluebutton/bigbluebutton-html-plugin-sdk#167
See screenshot ahead: