forked from onlook-dev/onlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Friendly name for layers (onlook-dev#78)
* Naming layers * Update next plugin * Update Babel plugin
- Loading branch information
Showing
24 changed files
with
161 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { compressSync, decompressSync, strFromU8, strToU8 } from 'fflate'; | ||
import { EditorAttributes } from '../constants'; | ||
import { TemplateNode } from '../models'; | ||
|
||
export function getTemplateNodeFromElement(element: Element): TemplateNode | undefined { | ||
const dataOnlookId = element.getAttribute(EditorAttributes.DATA_ONLOOK_ID); | ||
if (!dataOnlookId) { | ||
return; | ||
} | ||
const templateNode = decodeTemplateNode(dataOnlookId); | ||
return templateNode; | ||
} | ||
|
||
export function encodeTemplateNode(templateNode: TemplateNode) { | ||
const buffer = strToU8(JSON.stringify(templateNode)); | ||
const compressed = compressSync(buffer); | ||
const binaryString = Array.from(new Uint8Array(compressed)) | ||
.map((byte) => String.fromCharCode(byte)) | ||
.join(''); | ||
const base64 = btoa(binaryString); | ||
return base64; | ||
} | ||
|
||
export function decodeTemplateNode(base64: string): TemplateNode { | ||
const buffer = new Uint8Array( | ||
atob(base64) | ||
.split('') | ||
.map((c) => c.charCodeAt(0)), | ||
); | ||
const decompressed = decompressSync(buffer); | ||
const JsonString = strFromU8(decompressed); | ||
const templateNode = JSON.parse(JsonString) as TemplateNode; | ||
return templateNode; | ||
} | ||
|
||
export function compareTemplateNodes(node1: TemplateNode, node2: TemplateNode): number { | ||
if (node1.startTag.start.line < node2.startTag.start.line) { | ||
return -1; | ||
} else if (node1.startTag.start.line > node2.startTag.start.line) { | ||
return 1; | ||
} else { | ||
if (node1.startTag.start.column < node2.startTag.start.column) { | ||
return -1; | ||
} else if (node1.startTag.start.column > node2.startTag.start.column) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import logo from './logo.svg'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
Check <code className='underline'>config-override.js</code> to see how this was set up. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
<ReadDocs /> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
function ReadDocs() { | ||
return ( | ||
<a | ||
className="App-link" | ||
href="https://github.com/onlook-dev/studio" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Read Onlook docs | ||
</a> | ||
); | ||
} | ||
|
||
export default App; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,4 @@ | |
"tailwindcss": "^3.3.2", | ||
"typescript": "^4.9.5" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.