-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
BUGFIX: Render table dropdowns with correct icons #3898
base: 8.3
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const REGEX = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol 😅 i hope you dindt had to write this yourself? :D I think more simple it would be to just use base64 decode and done :D Edit: see comment above - i believe we dont need this at all hopefully There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can discuss other solutions of course :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I simplified that and now use base64 for the inline dataUri SVG stuff. |
||
whitespace: /\s+/g, | ||
urlHexPairs: /%[\dA-F]{2}/g, | ||
quotes: /"/g | ||
}; | ||
|
||
// Function to collapse whitespace in a string | ||
const collapseWhitespace = (str: string): string => | ||
str.trim().replace(REGEX.whitespace, ' '); | ||
|
||
// Function to encode data for a URI payload | ||
const dataURIPayload = (string: string): string => | ||
encodeURIComponent(string).replace(REGEX.urlHexPairs, specialHexEncode); | ||
|
||
// Function to handle special hex encoding | ||
const specialHexEncode = (match: string): string => { | ||
switch (match) { | ||
case '%20': | ||
return ' '; | ||
case '%3D': | ||
return '='; | ||
case '%3A': | ||
return ':'; | ||
case '%2F': | ||
return '/'; | ||
default: | ||
return match.toLowerCase(); // Compresses better | ||
} | ||
}; | ||
|
||
// Function to convert an SVG string to a tiny data URI | ||
const svgToDataUri = (svgString: string): string => { | ||
// Strip the Byte-Order Mark if the SVG has one | ||
if (svgString.charCodeAt(0) === 0xfeff) { | ||
svgString = svgString.slice(1); | ||
} | ||
|
||
const body = collapseWhitespace(svgString); | ||
return `data:image/svg+xml,${dataURIPayload(body)}`; | ||
}; | ||
|
||
// Add a static method to handle srcset conversions | ||
svgToDataUri.toSrcset = (svgString: string): string => | ||
svgToDataUri(svgString).replace(/ /g, '%20'); | ||
|
||
// Export the function as the default export | ||
export default svgToDataUri; |
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.
öhm do i get that right that we want to have the svgs as data-url and not as raw content string?
That can be done via the build setup. For the neos ui i introduced the convention that files ending with
.dataurl.svg
will get that treatment via the build setup already introduced via:#3836
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.
The issue here was that the content of
this.props.icon
is just the SVG markup.And that in a src tag is not working, and I bet that the build pipeline also doesn't handle it.