Skip to content

Commit

Permalink
Merge pull request #343 from dabapps/Export-component-types
Browse files Browse the repository at this point in the history
Export component types
  • Loading branch information
Danny-Robinson authored Oct 12, 2020
2 parents 6606232 + 9ee1b1b commit 1569083
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dabapps/roe",
"version": "0.12.0",
"version": "0.12.1",
"description": "A collection of React components, styles, mixins, and atomic CSS classes to aid with the development of web applications.",
"main": "dist/js/index.js",
"types": "dist/js/index.d.ts",
Expand Down
179 changes: 133 additions & 46 deletions src/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,134 @@
export { default as Alert } from './components/misc/alert';
export { default as AppRoot } from './components/app/root';
export { default as Anchor } from './components/misc/anchor';
export { default as Badge } from './components/misc/badge';
export { default as Banner } from './components/banners/banner';
export { default as Button } from './components/forms/button';
export { default as CodeBlock } from './components/misc/code-block';
export { default as Collapse } from './components/misc/collapse';
export { default as Column } from './components/grid/column';
export { default as Container } from './components/grid/container';
export { default as ContentBox } from './components/content/content-box';
export { default as ContentBoxHeader } from './components/content/content-box-header';
export { default as ContentBoxFooter } from './components/content/content-box-footer';
export { default as CookieBanner } from './components/banners/cookie-banner';
export { default as Alert, AlertProps } from './components/misc/alert';
export { default as AppRoot, AppRootProps } from './components/app/root';
export { default as Anchor, AnchorProps } from './components/misc/anchor';
export { default as Badge, BadgeProps } from './components/misc/badge';
export { default as Banner, BannerProps } from './components/banners/banner';
export { default as Button, ButtonProps } from './components/forms/button';
export {
default as CodeBlock,
CodeBlockProps,
} from './components/misc/code-block';
export { default as Collapse, CollapseProps } from './components/misc/collapse';
export { default as Column, ColumnProps } from './components/grid/column';
export {
default as Container,
ContainerProps,
} from './components/grid/container';
export {
default as ContentBox,
ContentBoxProps,
} from './components/content/content-box';
export {
default as ContentBoxHeader,
ContentBoxHeaderProps,
} from './components/content/content-box-header';
export {
default as ContentBoxFooter,
ContentBoxFooterProps,
} from './components/content/content-box-footer';
export {
default as CookieBanner,
CookieBannerProps,
} from './components/banners/cookie-banner';
export { CookieBannerRenderProps } from './components/banners/cookie-banner';
export { default as DabIpsum } from './components/prototyping/dab-ipsum';
export { default as Footer } from './components/navigation/footer';
export { default as FormGroup } from './components/forms/form-group';
export { default as Highlight } from './components/misc/highlight';
export { default as InputGroup } from './components/forms/input-group';
export { default as InputGroupAddon } from './components/forms/input-group-addon';
export { default as InputWithPrefixSuffix } from './components/precomposed/input-with-prefix-suffix';
export { default as Modal } from './components/modals/modal';
export { default as ModalBody } from './components/modals/modal-body';
export { default as ModalCloseIcon } from './components/modals/modal-close-icon';
export { default as ModalFooter } from './components/modals/modal-footer';
export { default as ModalHeader } from './components/modals/modal-header';
export { default as ModalRenderer } from './components/modals/modal-renderer';
export { default as Nav } from './components/navigation/nav';
export { default as NavBar } from './components/navigation/nav-bar';
export { default as NavItem } from './components/navigation/nav-item';
export { default as Pagination } from './components/pagination/pagination';
export { default as PaginationDisplay } from './components/pagination/pagination-display';
export { default as Row } from './components/grid/row';
export { default as Section } from './components/content/section';
export { default as SideBar } from './components/navigation/side-bar';
export { default as SpacedGroup } from './components/misc/spaced-group';
export { default as SpeechBubble } from './components/misc/speech-bubble';
export { default as Tabs } from './components/tabs/tabs';
export { default as Tab } from './components/tabs/tab';
export { default as Table } from './components/tables/table';
export { default as TableBody } from './components/tables/table-body';
export { default as TableCell } from './components/tables/table-cell';
export { default as TableHead } from './components/tables/table-head';
export { default as TableHeader } from './components/tables/table-header';
export { default as TableRow } from './components/tables/table-row';
export { default as Well } from './components/misc/well';
export {
default as DabIpsum,
DabIpsumProps,
} from './components/prototyping/dab-ipsum';
export { default as Footer, FooterProps } from './components/navigation/footer';
export {
default as FormGroup,
FormGroupProps,
} from './components/forms/form-group';
export {
default as Highlight,
HighlightProps,
} from './components/misc/highlight';
export {
default as InputGroup,
InputGroupProps,
} from './components/forms/input-group';
export {
default as InputGroupAddon,
InputGroupAddonProps,
} from './components/forms/input-group-addon';
export {
default as InputWithPrefixSuffix,
InputWithPrefixSuffixProps,
} from './components/precomposed/input-with-prefix-suffix';
export { default as Modal, ModalProps } from './components/modals/modal';
export {
default as ModalBody,
ModalBodyProps,
} from './components/modals/modal-body';
export {
default as ModalCloseIcon,
ModalCloseIconProps,
} from './components/modals/modal-close-icon';
export {
default as ModalFooter,
ModalFooterProps,
} from './components/modals/modal-footer';
export {
default as ModalHeader,
ModalHeaderProps,
} from './components/modals/modal-header';
export {
default as ModalRenderer,
ModalRendererProps,
} from './components/modals/modal-renderer';
export { default as Nav, NavProps } from './components/navigation/nav';
export {
default as NavBar,
NavBarProps,
} from './components/navigation/nav-bar';
export {
default as NavItem,
NavItemProps,
} from './components/navigation/nav-item';
export {
default as Pagination,
PaginationProps,
} from './components/pagination/pagination';
export {
default as PaginationDisplay,
PaginationDisplayProps,
} from './components/pagination/pagination-display';
export { default as Row, RowProps } from './components/grid/row';
export { default as Section, SectionProps } from './components/content/section';
export {
default as SideBar,
SideBarProps,
} from './components/navigation/side-bar';
export {
default as SpacedGroup,
SpacedGroupProps,
} from './components/misc/spaced-group';
export {
default as SpeechBubble,
SpeechBubbleProps,
} from './components/misc/speech-bubble';
export { default as Tabs, TabsProps } from './components/tabs/tabs';
export { default as Tab, TabProps } from './components/tabs/tab';
export { default as Table, TableProps } from './components/tables/table';
export {
default as TableBody,
TableBodyProps,
} from './components/tables/table-body';
export {
default as TableCell,
TableCellProps,
} from './components/tables/table-cell';
export {
default as TableHead,
TableHeadProps,
} from './components/tables/table-head';
export {
default as TableHeader,
TableHeaderProps,
} from './components/tables/table-header';
export {
default as TableRow,
TableRowProps,
} from './components/tables/table-row';
export { default as Well, WellProps } from './components/misc/well';
3 changes: 3 additions & 0 deletions src/ts/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export type ComponentType<P> =
| React.ComponentClass<P>
| React.StatelessComponent<P>;

/**
* @internal
*/
export type StoreState = Partial<{
hasFixedNavBar: boolean;
hasStickyFooter: boolean;
Expand Down
10 changes: 2 additions & 8 deletions tests/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,21 @@ describe('components', () => {
});
});

it('should all be exported from the index file', () => {
it('should all be exported from the index file with their props', () => {
components.forEach(filePath => {
const content = fs.readFileSync(filePath, UTF8);

const defaultExport = MATCHES_DEFAULT_EXPORT.exec(content);

if (!defaultExport) {
throw new Error(`No default export in component at ${filePath}`);
}

if (!fs.existsSync(INDEX_FILE_PATH)) {
throw new Error(`Could not find index file at ${INDEX_FILE_PATH}`);
}

const indexContent = fs.readFileSync(INDEX_FILE_PATH, UTF8);

const indexRegex = new RegExp(
`^export\\s+{\\s+default\\s+as\\s+${defaultExport[1]},?\\s+}\\s+from\\s+'[a-z/.-]+';$`,
`^export\\s+{\\s+default\\s+as\\s+${defaultExport[1]},?\\s+${defaultExport[1]}Props,?\\s+}\\s+from\\s+'[a-z/.-]+';$`,
'm'
);

if (!indexRegex.test(indexContent)) {
throw new Error(
`Component ${defaultExport[1]} is not exported from default at ${INDEX_FILE_PATH}`
Expand Down
1 change: 1 addition & 0 deletions tsconfig.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"declaration": true,
"sourceMap": true,
"listEmittedFiles": true,
"stripInternal": true,
"rootDir": "./src/ts/",
"outDir": "./dist/js/"
},
Expand Down

0 comments on commit 1569083

Please sign in to comment.