Skip to content

Commit

Permalink
Swap the css icon to use the new official one (#660)
Browse files Browse the repository at this point in the history
* fix: update css icon, fix remote svg icon content

* docs(changeset): Fix RemoteSvgIcon inner content

* docs(changeset): Fix WindowTab attributes
  • Loading branch information
riccardoperra authored Dec 21, 2024
1 parent 4ed8ff1 commit 439c854
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-parents-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codeimage/ui': patch
---

Fix RemoteSvgIcon inner content
5 changes: 5 additions & 0 deletions .changeset/wise-coins-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codeimage/config': patch
---

Fix WindowTab attributes
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export interface WindowTabProps {
export function WindowTab(
props: ParentProps<WindowTabProps & JSX.IntrinsicElements['div']>,
) {
const [, others] = splitProps(props, ['class', 'ref', 'style']);
const [, others] = splitProps(props, [
'class',
'ref',
'style',
'rightContent',
'content',
]);

return (
<div
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/lib/base/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export const SUPPORTED_LANGUAGES: readonly LanguageDefinition[] = [
{
name: 'css',
extension: '.css',
content: () => import('material-icon-theme/icons/css.svg?raw'),
content: () => import('../icons/css.svg?raw'),
matcher: /^.*\.(css)$/,
},
{
Expand Down
6 changes: 6 additions & 0 deletions packages/config/src/lib/icons/css.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion packages/ui/src/lib/primitives/Icon/RemoteSvgIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ export function RemoteSvgIcon(props: SvgExternalIconProps): JSXElement {

const innerHTML = randomizeSvgUrlIds(svgResponse);

return {
const parsedDocument = new DOMParser().parseFromString(
innerHTML,
'text/html',
);
const svg = parsedDocument.body.childNodes[0] as SVGElement;

return {
innerHTML: (svg as SVGElement).innerHTML,
viewBox: svg.getAttribute('viewBox') || undefined,
};
});

Expand Down

0 comments on commit 439c854

Please sign in to comment.