Skip to content

Commit

Permalink
fix: source tags fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Feb 24, 2020
1 parent 6497d96 commit f455cd8
Show file tree
Hide file tree
Showing 19 changed files with 955 additions and 555 deletions.
1 change: 0 additions & 1 deletion blocks/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"global": "^4.3.2",
"js-string-escape": "^1.0.1",
"polished": "^3.4.4",
"prettier": "^1.19.1",
"prism-react-renderer": "^1.0.2",
"qs": "^6.9.1",
"react": "^16.8.3",
Expand Down
273 changes: 225 additions & 48 deletions blocks/core/src/Source/Source.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,68 +75,246 @@ export const sample = () => {
},
};

export const props = () => {
return (
<Source
args={[{ value: 'props' }]}
>{`export const story = props => (<Source {...props} />)`}</Source>
);
};

const code = `
export const story = ({ height, weight, style: { border, color }}) => (
export const simplyStoryFn = () => (
<Source
height={height}
weight={weight}
border={border}
color={color}
/>);
`;
args={[
{
value: [
{
value: 'text',
name: 'text',
loc: {
start: {
line: 0,
column: 3,
},
end: {
line: 0,
column: 7,
},
},
usage: [
{
loc: {
start: {
line: 0,
column: 14,
},
end: {
line: 0,
column: 18,
},
},
},
],
},
],
loc: {
start: {
line: 0,
column: 1,
},
end: {
line: 0,
column: 9,
},
},
},
]}
>
{`({ text }) => text;`}
</Source>
);

export const multiProps = () => {
export const props = () => {
return (
<Source
args={[
{ value: 'height' },
{ value: 'weight' },
{ value: 'border' },
{ value: 'color' },
{
value: 'props',
name: 'props',
loc: {
start: {
line: 0,
column: 0,
},
end: {
line: 0,
column: 5,
},
},
usage: [
{
loc: {
start: {
line: 0,
column: 19,
},
end: {
line: 0,
column: 24,
},
},
},
],
},
]}
>
{code}
{`props => (<div {...props} />);`}
</Source>
);
};

export const noPrettier = () => {
return (
<Source
prettier={null}
args={[
{ value: 'height' },
{ value: 'weight' },
{ value: 'border' },
{ value: 'color' },
]}
>
{code}
</Source>
);
};
const code = `({ height, weight, style: { border, color } }) => (
<div height={height} weight={weight} border={border} color={color} />
);
`;

export const prettierFormatting = () => {
export const multiProps = () => {
return (
<Source
prettier={{
tabWidth: 4,
bracketSpacing: false,
printWidth: 40,
}}
args={[
{ value: 'height' },
{ value: 'weight' },
{ value: 'border' },
{ value: 'color' },
{
value: [
{
value: 'height',
name: 'height',
loc: {
start: {
line: 0,
column: 3,
},
end: {
line: 0,
column: 9,
},
},
usage: [
{
loc: {
start: {
line: 1,
column: 15,
},
end: {
line: 1,
column: 21,
},
},
},
],
},
{
value: 'weight',
name: 'weight',
loc: {
start: {
line: 0,
column: 11,
},
end: {
line: 0,
column: 17,
},
},
usage: [
{
loc: {
start: {
line: 1,
column: 31,
},
end: {
line: 1,
column: 37,
},
},
},
],
},
{
value: [
{
value: 'border',
name: 'border',
loc: {
start: {
line: 0,
column: 28,
},
end: {
line: 0,
column: 34,
},
},
usage: [
{
loc: {
start: {
line: 1,
column: 47,
},
end: {
line: 1,
column: 53,
},
},
},
],
},
{
value: 'color',
name: 'color',
loc: {
start: {
line: 0,
column: 36,
},
end: {
line: 0,
column: 41,
},
},
usage: [
{
loc: {
start: {
line: 1,
column: 62,
},
end: {
line: 1,
column: 67,
},
},
},
],
},
],
name: 'style',
loc: {
start: {
line: 0,
column: 26,
},
end: {
line: 0,
column: 48,
},
},
},
],
loc: {
start: {
line: 0,
column: 1,
},
end: {
line: 0,
column: 50,
},
},
},
]}
>
{code}
Expand All @@ -147,7 +325,6 @@ export const prettierFormatting = () => {
export const controlsValues = () => {
return (
<Source
prettier={null}
args={[
{
loc: {
Expand Down
Loading

0 comments on commit f455cd8

Please sign in to comment.