Skip to content

Commit

Permalink
feat: custom Testing page
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Aug 29, 2020
1 parent 1ad543b commit c47e0ba
Show file tree
Hide file tree
Showing 19 changed files with 184 additions and 71 deletions.
34 changes: 34 additions & 0 deletions examples/gatsby/.config/TestingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable react/display-name */
import React from 'react';
import {
Playground,
PropsTable,
Story,
Description,
} from '@component-controls/blocks';
import { getControlsCount } from '@component-controls/core';
import { useCurrentStory } from '@component-controls/store';
import { AllyBlock } from '@component-controls/axe-plugin';
import { ViewportBlock } from '@component-controls/viewport-plugin';

export const TestingPage = () => {
const story = useCurrentStory();
const controlsCount = getControlsCount(story?.controls);
return (
<>
<Description />
{controlsCount > 0 && (
<>
<Playground title=".">
<Story id="." />
</Playground>

<PropsTable of="." title="Controls" visibility="controls" />
</>
)}
<AllyBlock title="A11y tests" />
<ViewportBlock title="Viewport"/>
</>
);
}

2 changes: 1 addition & 1 deletion examples/gatsby/.config/buildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
pages: {
story: {
basePath: 'api/',
tabs: [{ route: 'page' }, { route: 'test' }, { route: 'viewport' }],
tabs: [{ route: 'page' }, { route: 'test' }],
},
blog: {
basePath: 'blogs/',
Expand Down
6 changes: 2 additions & 4 deletions examples/gatsby/.config/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { jsx, Box, Text } from 'theme-ui';
import { RunOnlyConfiguration, defaultRunConfig } from "@component-controls/core";
import { Link } from "@component-controls/components";
import { OctofaceIcon } from '@primer/octicons-react';
import { AllyPage } from "@component-controls/axe-plugin";
import { ViewportPage } from "@component-controls/viewport-plugin";
import { TestingPage } from "./TestingPage";

const categories = ['Introduction', 'Application','Controls','Blocks', 'Editors', 'Components', 'Plugins']

Expand All @@ -25,8 +24,7 @@ const config: RunOnlyConfiguration = {
label: 'API',
tabs: [
...defaultRunConfig.pages.story.tabs,
{ title: 'Testing', render: () => <AllyPage /> },
{ title: 'Viewport', render: () => <ViewportPage /> },
{ title: 'Testing', render: () => <TestingPage /> },
],
},
tutorial: {
Expand Down
2 changes: 2 additions & 0 deletions examples/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
},
"dependencies": {
"@component-controls/axe-plugin": "^1.22.1",
"@component-controls/blocks": "^1.22.1",
"@component-controls/core": "^1.22.1",
"@component-controls/gatsby-theme-stories": "^1.22.1",
"@component-controls/viewport-plugin": "^1.22.1",
"@theme-ui/presets": "^0.4.0-rc.1",
Expand Down
34 changes: 34 additions & 0 deletions examples/nextjs/.config/TestingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable react/display-name */
import React from 'react';
import {
Playground,
PropsTable,
Story,
Description,
} from '@component-controls/blocks';
import { getControlsCount } from '@component-controls/core';
import { useCurrentStory } from '@component-controls/store';
import { AllyBlock } from '@component-controls/axe-plugin';
import { ViewportBlock } from '@component-controls/viewport-plugin';

export const TestingPage = () => {
const story = useCurrentStory();
const controlsCount = getControlsCount(story?.controls);
return (
<>
<Description />
{controlsCount > 0 && (
<>
<Playground title=".">
<Story id="." />
</Playground>

<PropsTable of="." title="Controls" visibility="controls" />
</>
)}
<AllyBlock title="A11y tests" />
<ViewportBlock title="Viewport"/>
</>
);
}

2 changes: 1 addition & 1 deletion examples/nextjs/.config/buildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
pages: {
story: {
basePath: 'api/',
tabs: [{ route: 'page' }, { route: 'test' }, { route: 'viewport' }],
tabs: [{ route: 'page' }, { route: 'test' }],
},
blog: {
basePath: 'blogs/',
Expand Down
6 changes: 2 additions & 4 deletions examples/nextjs/.config/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { jsx, Box, Text } from 'theme-ui';
import { RunOnlyConfiguration, defaultRunConfig } from "@component-controls/core";
import { Link } from "@component-controls/components";
import { OctofaceIcon } from '@primer/octicons-react';
import { AllyPage } from "@component-controls/axe-plugin";
import { ViewportPage } from "@component-controls/viewport-plugin";
import { TestingPage } from "./TestingPage";

const categories = ['Introduction', 'Application','Controls','Blocks', 'Editors', 'Components', 'Plugins']

Expand All @@ -25,8 +24,7 @@ const config: RunOnlyConfiguration = {
label: 'API',
tabs: [
...defaultRunConfig.pages.story.tabs,
{ title: 'Testing', render: () => <AllyPage /> },
{ title: 'Viewport', render: () => <ViewportPage /> },
{ title: 'Testing', render: () => <TestingPage /> },
],
sideNav: {
collapseSingle: false,
Expand Down
2 changes: 2 additions & 0 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
},
"dependencies": {
"@component-controls/axe-plugin": "^1.22.1",
"@component-controls/blocks": "^1.22.1",
"@component-controls/core": "^1.22.1",
"@component-controls/nextjs-plugin": "^1.22.1",
"@component-controls/viewport-plugin": "^1.22.1",
"@theme-ui/presets": "^0.4.0-rc.1",
Expand Down
34 changes: 34 additions & 0 deletions examples/starter/.config/TestingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable react/display-name */
import React from 'react';
import {
Playground,
PropsTable,
Story,
Description,
} from '@component-controls/blocks';
import { getControlsCount } from '@component-controls/core';
import { useCurrentStory } from '@component-controls/store';
import { AllyBlock } from '@component-controls/axe-plugin';
import { ViewportBlock } from '@component-controls/viewport-plugin';

export const TestingPage = () => {
const story = useCurrentStory();
const controlsCount = getControlsCount(story?.controls);
return (
<>
<Description />
{controlsCount > 0 && (
<>
<Playground title=".">
<Story id="." />
</Playground>

<PropsTable of="." title="Controls" visibility="controls" />
</>
)}
<AllyBlock title="A11y tests" />
<ViewportBlock title="Viewport"/>
</>
);
}

2 changes: 1 addition & 1 deletion examples/starter/.config/buildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
story: {
tabs: [
...defaultBuildConfig.pages.story.tabs,
{ route: 'viewport' },
{ route: 'test' },
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions examples/starter/.config/runtime.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { RunOnlyConfiguration, defaultRunConfig } from "@component-controls/core";
import { ViewportPage } from "@component-controls/viewport-plugin";
import { TestingPage } from "./TestingPage";

const config: RunOnlyConfiguration = {
siteTitle: `awLib`,
Expand All @@ -10,7 +10,7 @@ const config: RunOnlyConfiguration = {
story: {
tabs: [
...defaultRunConfig.pages.story.tabs,
{ title: 'Viewport', render: () => <ViewportPage /> },
{ title: 'Testing', render: () => <TestingPage /> },
],
},
},
Expand Down
4 changes: 4 additions & 0 deletions examples/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
"url": "https://github.com/atanasster/gatsby-controls-starter.git"
},
"dependencies": {
"@component-controls/axe-plugin": "^1.22.1",
"@component-controls/blocks": "^1.22.1",
"@component-controls/core": "^1.22.1",
"@component-controls/gatsby-theme-stories": "^1.22.1",
"@component-controls/nextjs-plugin": "^1.22.1",
"@component-controls/viewport-plugin": "^1.22.1",
"emotion": "^10.0.27",
"emotion-server": "^10.0.27",
"gatsby": "^2.23.11",
Expand Down
1 change: 0 additions & 1 deletion examples/storybook-6-no-docs/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
pages: [
require.resolve('@component-controls/storybook/full-page'),
require.resolve('./testing-page.js'),
require.resolve('./viewport-page.js'),
],
webpack: ['instrument',
{
Expand Down
34 changes: 32 additions & 2 deletions examples/storybook-6-no-docs/.storybook/testing-page.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
/* eslint-disable react/display-name */
import React from 'react';
import { AllyPage } from '@component-controls/axe-plugin';
import {
Playground,
PropsTable,
Story,
Description,
} from '@component-controls/blocks';
import { getControlsCount } from '@component-controls/core';
import { useCurrentStory } from '@component-controls/store';
import { AllyBlock } from '@component-controls/axe-plugin';
import { ViewportBlock } from '@component-controls/viewport-plugin';
import { DocsContainer } from '@component-controls/storybook/DocsContainer';

const TestingPage = () => {
const story = useCurrentStory();
const controlsCount = getControlsCount(story?.controls);
return (
<>
<Description />
{controlsCount > 0 && (
<>
<Playground title=".">
<Story id="." />
</Playground>

<PropsTable of="." title="Controls" visibility="controls" />
</>
)}
<AllyBlock title="A11y tests" />
<ViewportBlock title="Viewport"/>
</>
);
}

export default {
key: 'test',
title: 'Testing',
render: ({ active }) => {
return (
<DocsContainer active={active}>
<AllyPage />
<TestingPage />
</DocsContainer>
);
},
Expand Down
16 changes: 0 additions & 16 deletions examples/storybook-6-no-docs/.storybook/viewport-page.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/storybook-6/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module.exports = {
pages: [
require.resolve('@component-controls/storybook/full-page'),
require.resolve('./testing-page'),
require.resolve('./viewport-page'),
],
propsPanel: true,
storySourcePanel: true,
Expand Down
34 changes: 32 additions & 2 deletions examples/storybook-6/.storybook/testing-page.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
/* eslint-disable react/display-name */
import React from 'react';
import { AllyPage } from '@component-controls/axe-plugin';
import {
Playground,
PropsTable,
Story,
Description,
} from '@component-controls/blocks';
import { getControlsCount } from '@component-controls/core';
import { useCurrentStory } from '@component-controls/store';
import { AllyBlock } from '@component-controls/axe-plugin';
import { ViewportBlock } from '@component-controls/viewport-plugin';
import { DocsContainer } from '@component-controls/storybook/DocsContainer';

const TestingPage = () => {
const story = useCurrentStory();
const controlsCount = getControlsCount(story?.controls);
return (
<>
<Description />
{controlsCount > 0 && (
<>
<Playground title=".">
<Story id="." />
</Playground>

<PropsTable of="." title="Controls" visibility="controls" />
</>
)}
<AllyBlock title="A11y tests" />
<ViewportBlock title="Viewport"/>
</>
);
}

export default {
key: 'test',
title: 'Testing',
render: ({ active }) => {
return (
<DocsContainer active={active}>
<AllyPage />
<TestingPage />
</DocsContainer>
);
},
Expand Down
16 changes: 0 additions & 16 deletions examples/storybook-6/.storybook/viewport-page.js

This file was deleted.

21 changes: 1 addition & 20 deletions plugins/axe-plugin/src/AllyPage/AllyPage.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
import React, { FC } from 'react';
import {
Playground,
PropsTable,
Story,
Description,
} from '@component-controls/blocks';
import { getControlsCount } from '@component-controls/core';
import { useCurrentStory } from '@component-controls/store';

import { Description } from '@component-controls/blocks';
import { AllyBlock } from '../AllyBlock';

export const AllyPage: FC = () => {
const story = useCurrentStory();
const controlsCount = getControlsCount(story?.controls);
return (
<>
<Description />
{controlsCount > 0 && (
<>
<Playground title=".">
<Story id="." />
</Playground>

<PropsTable of="." title="Controls" visibility="controls" />
</>
)}
<AllyBlock title="A11y tests" />
</>
);
Expand Down

0 comments on commit c47e0ba

Please sign in to comment.