Skip to content

Commit

Permalink
Merge pull request #150 from NearSocial/release-2.5.2
Browse files Browse the repository at this point in the history
Release 2.5.2
  • Loading branch information
calebjacob authored Oct 25, 2023
2 parents 32a404f + 71d02ac commit 9fe2d4e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# Changelog

## 2.5.2

- Use `styled-components` in combination with `customElements` like `Link`:

```jsx
const MyLink = styled("Link")`
color: red;
`;

return (
<MyLink href="/my/page">
Click Me!
</MyLink>
);
```

## 2.5.1

- FIX: Add back `Ethers.send`, that was incorrectly removed as part of the /~https://github.com/NearSocial/VM/pull/128
- FIX: Disable `is` attribute to avoid conflicts with React. Reported by @brunomodificato
- FIX: Disable `is` attribute to avoid conflicts with React. Reported by BrunoModificato from OtterSec.

## 2.5.0

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-social-vm",
"version": "2.5.1",
"version": "2.5.2",
"description": "Near Social VM",
"main": "dist/index.js",
"files": [
Expand Down
9 changes: 6 additions & 3 deletions src/lib/vm/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ const assertValidObject = (o) => {
};

const assertRadixComponent = (element) => {
if (!element) return;

let isRadixElement = Object.keys(RadixTags).includes(element.split(".")[0]);

if (!isRadixElement) return;
Expand Down Expand Up @@ -1011,14 +1013,15 @@ class VmStack {
const args = this.getArray(code.tag.arguments);
const arg = args?.[0];
const RadixComp = assertRadixComponent(arg);
const CustomElement = this.vm.near.config.customElements[arg];

if (!isStyledComponent(arg) && !RadixComp) {
if (!isStyledComponent(arg) && !RadixComp && !CustomElement) {
throw new Error(
'styled() can only take `styled` components or valid Radix components (EG: "Accordion.Trigger")'
'styled() can only take `styled` components, Radix component names (EG: "Accordion.Trigger"), or a customElement name (EG: "Link")'
);
}

styledTemplate = styled(RadixComp ?? arg);
styledTemplate = styled(CustomElement ?? RadixComp ?? arg);
} else {
if (key === "keyframes") {
styledTemplate = keyframes;
Expand Down

0 comments on commit 9fe2d4e

Please sign in to comment.