Skip to content

Commit

Permalink
stringinator
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnath committed Mar 5, 2024
1 parent 1a72109 commit 21b04ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { setCustomElementsManifest } from '@storybook/web-components';
import customElements from '../custom-elements.json';
import { globalTypesPrimer, decoratorsPrimer } from './primer-preview';
import { viewports } from './viewports';
import { stringify, parseify } from '../src/utils';
import { stringify, stringinator, parseify } from '../src/utils';
import "./storybook.css";

setCustomElementsManifest(customElements);
Expand All @@ -16,6 +16,7 @@ global.attrGen = (args) => Object.entries(args)
.join(' ');

global.stringify = stringify;
global.stringinator = stringinator;
global.parseify = parseify;

/** @type { import('@storybook/web-components').Preview } */
Expand Down
6 changes: 3 additions & 3 deletions src/github/user/user.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export default {
delete args.repos2;
}
let attributes = attrGen({...args});
console.log('attributes', {...attributes})
console.log('attributes', attributes)
args.repos = repos;
if (repos) {
console.log('repos', repos)
console.log('typeofrepos', typeof repos)
if (typeof repos !== 'string') repos = stringify(repos);
if (typeof repos !== 'string') repos = stringinator(repos);
console.log('repos>>2', repos)
attributes += `\nrepos="${repos}"`;
}
Expand All @@ -51,7 +51,7 @@ export const UserRepos = {
args: {
...User.args,
name: 'Scoot Nerth',
repos2: stringify([parseFetchedRepo(repoProfileComponents), parseFetchedRepo(repoStorydocker)]),
repos2: stringinator([parseFetchedRepo(repoProfileComponents), parseFetchedRepo(repoStorydocker)]),
},
play: async ({ args, canvasElement, step }) => {
console.log('UserRepos = canva', canvasElement.closest('body').innerHTML)
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const stringify = (obj) => {
console.log('FUCKING ughughugh222', ugh);
return ugh;
};
export const stringinator = (obj) => JSON.stringify(obj).replace(/"/g, "||||");

/**
* Parse a stringified object with quotes escaped
Expand Down

0 comments on commit 21b04ab

Please sign in to comment.