Skip to content
This repository was archived by the owner on Aug 26, 2021. It is now read-only.

Seperate react components into single files #728

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
59c29e4
Renamed and moved src/js react files to src/react
adamzerella Apr 8, 2019
8ab32da
Moved jquery components into seperate folders
adamzerella Apr 8, 2019
ae6adff
Corrected import for form tests
adamzerella Apr 8, 2019
180258e
Updating template package.json
adamzerella Apr 8, 2019
629911a
Updated compile/precompile directory structures
adamzerella Apr 8, 2019
9e8f869
Split calllout into seperate files
adamzerella Apr 8, 2019
535f942
Refactored component short name
adamzerella Apr 8, 2019
fed44f4
Seperated react src files
adamzerella Apr 8, 2019
d269430
Modified helper.js
adamzerella Apr 9, 2019
4d00dc6
Trailing removing webpack build from main build step, moving to watch
adamzerella Apr 10, 2019
b8da03a
Updated scripts/helper to get reactDeps from lib
adamzerella Apr 10, 2019
c6e70e4
Corrected filenames for react components
adamzerella Apr 10, 2019
c2b46da
trailing webpack before libs are built :(
adamzerella Apr 10, 2019
7326f69
Added custom case for 'animate' when required in react
adamzerella Apr 10, 2019
a83da30
Fixed old src/react/react.js file ref in package.json
adamzerella Apr 10, 2019
e639088
Added basic react proptype jsdoc
adamzerella Apr 2, 2019
c11a01f
Corrected git rebase diff
adamzerella Apr 10, 2019
d9e81a7
Added previously removed name version from main control-input component
adamzerella Apr 10, 2019
06720ce
Added back replacement for lib/react/react.js
adamzerella Apr 10, 2019
a95f0d0
Removed form from package.json tests
adamzerella Apr 10, 2019
0930a20
Updating babel transform file
adamzerella Apr 10, 2019
b4086e8
Removed comments from babel transform
adamzerella Apr 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .templates/new-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"serve": "browser-sync tests --files \"tests/**/*.html, tests/**/*.css, tests/**/*.js\"",

"watch:js": "onchange \"src/js/*.js\" -- npm run build:js",
"watch:jsx": "onchange \"src/js/react.js\" \"tests/react/index.js\" -- npm run build",
"watch:jsx": "onchange \"src/react/*.js\" \"tests/react/index.js\" -- npm run build",
"watch:sass": "onchange \"src/sass/*.scss\" \"tests/site/test.scss\" -- npm run build",
"watch": "npm run build && npm-run-all --parallel serve watch:*"
},
Expand All @@ -52,11 +52,11 @@
"path": "lib/js/module.js"
},
"react": {
"path": "lib/js/react.js"
"path": "lib/react/react.js"
}
}
},
"main": "lib/js/react.es5.js",
"main": "lib/react/react.es5.js",
"dependencies": {
"@gov.au/pancake": "~1",
"@gov.au/pancake-js": "~1",
Expand Down
6 changes: 3 additions & 3 deletions packages/accordion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"serve": "browser-sync tests --files \"tests/**/*.html, tests/**/*.css, tests/**/*.js\"",

"watch:js": "onchange \"src/js/*.js\" -- npm run build:js",
"watch:jsx": "onchange \"src/js/react.js\" \"tests/react/index.js\" -- npm run build",
"watch:jsx": "onchange \"src/react/*.js\" \"tests/react/index.js\" -- npm run build",
"watch:sass": "onchange \"src/sass/*.scss\" \"tests/site/test.scss\" -- npm run build",
"watch": "npm run build && npm-run-all --parallel serve watch:*"
},
Expand All @@ -52,11 +52,11 @@
"path": "lib/js/module.js"
},
"react": {
"path": "lib/js/react.js"
"path": "lib/react/react.js"
}
}
},
"main": "lib/js/react.es5.js",
"main": "lib/react/react.es5.js",
"dependencies": {
"@gov.au/pancake": "~1",
"@gov.au/pancake-js": "~1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class AUaccordion extends React.PureComponent {
/**
* Toggle an accordion on click
*
* @param {event object} event - The event object of the click
* @param {object} event - The event object of the click
*/
toggle( event ) {
event.preventDefault();
Expand Down Expand Up @@ -391,15 +391,45 @@ class AUaccordion extends React.PureComponent {
};

AUaccordion.propTypes = {
/**
* The elements inside.
*/
children: PropTypes.node.isRequired,
/**
* The headline of the accordion
*/
header: PropTypes.string.isRequired,
/**
* Closed state, optional
*/
closed: PropTypes.bool,
/**
* Speed of the animation in ms, optional
*/
speed: PropTypes.number,
/**
* A dark variation of the component
*/
dark: PropTypes.bool,
/**
* A function executed when the accordion opens, optional
*/
onOpen: PropTypes.func,
/**
* A function executed after the accordion opened, optional
*/
afterOpen: PropTypes.func,
/**
* A function executed when the accordion closes, optional
*/
onClose: PropTypes.func,
/**
* A function executed when the accordion closes, optional
*/
afterClose: PropTypes.func,
/**
* The class name for the element, optional.
*/
className: PropTypes.string,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/body/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"serve": "browser-sync tests --files \"tests/**/*.html, tests/**/*.css, tests/**/*.js\"",

"watch:js": "onchange \"src/js/*.js\" -- npm run build:js",
"watch:jsx": "onchange \"src/js/react.js\" \"tests/react/index.js\" -- npm run build",
"watch:jsx": "onchange \"src/react/*.js\" \"tests/react/index.js\" -- npm run build",
"watch:sass": "onchange \"src/sass/*.scss\" \"tests/site/test.scss\" -- npm run build",
"watch": "npm run build && npm-run-all --parallel serve watch:*"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/breadcrumbs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"serve": "browser-sync tests --files \"tests/**/*.html, tests/**/*.css, tests/**/*.js\"",

"watch:js": "onchange \"src/js/*.js\" -- npm run build:js",
"watch:jsx": "onchange \"src/js/react.js\" \"tests/react/index.js\" -- npm run build",
"watch:jsx": "onchange \"src/react/*.js\" \"tests/react/index.js\" -- npm run build",
"watch:sass": "onchange \"src/sass/*.scss\" \"tests/site/test.scss\" -- npm run build",
"watch": "npm run build && npm-run-all --parallel serve watch:*"
},
Expand All @@ -50,11 +50,11 @@
"sass-versioning": true
},
"react": {
"path": "lib/js/react.js"
"path": "lib/react/react.js"
}
}
},
"main": "lib/js/react.es5.js",
"main": "lib/react/react.es5.js",
"dependencies": {
"@gov.au/pancake": "~1",
"@gov.au/pancake-sass": "~2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,26 @@ const AUbreadcrumbs = ({ dark, label, items, linkComponent, className = '', ...a
);

AUbreadcrumbs.propTypes = {
/**
* A dark variation of the component.
*/
dark: PropTypes.bool,
/**
* Provide the aria label
*/
label: PropTypes.string.isRequired,
/**
* The link, text and props for each of the breadcrumbs
*/
items: PropTypes.arrayOf(
PropTypes.shape({
link: PropTypes.string,
text: PropTypes.string.isRequired,
})
).isRequired,
/**
* The component used for the link, optional.
*/
linkComponent: PropTypes.oneOfType([ PropTypes.string, PropTypes.func ])
};

Expand Down
6 changes: 3 additions & 3 deletions packages/buttons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"serve": "browser-sync tests --files \"tests/**/*.html, tests/**/*.css, tests/**/*.js\"",

"watch:js": "onchange \"src/js/*.js\" -- npm run build:js",
"watch:jsx": "onchange \"src/js/react.js\" \"tests/react/index.js\" -- npm run build",
"watch:jsx": "onchange \"src/react/*.js\" \"tests/react/index.js\" -- npm run build",
"watch:sass": "onchange \"src/sass/*.scss\" \"tests/site/test.scss\" -- npm run build",
"watch": "npm run build && npm-run-all --parallel serve watch:*"
},
Expand All @@ -48,11 +48,11 @@
"sass-versioning": true
},
"react": {
"path": "lib/js/react.js"
"path": "lib/react/react.js"
}
}
},
"main": "lib/js/react.es5.js",
"main": "lib/react/react.es5.js",
"dependencies": {
"@gov.au/pancake": "~1",
"@gov.au/pancake-sass": "~2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,34 @@ const AUbutton = ({ linkComponent, link, children, as, dark, type, block, classN
};

AUbutton.propTypes = {
/**
* If an link is set the button will render as a link.
*/
link: PropTypes.string,
/**
* Anything inside.
*/
children: PropTypes.node.isRequired,
/**
* The kind of button, secondary or tertiary.
*/
as: PropTypes.oneOf([ 'primary', 'secondary', 'tertiary' ]).isRequired,
/**
* A dark variation of the component.
*/
dark: PropTypes.bool,
type: PropTypes.string,
/**
* The block option to make the button fill the available width.
*/
block: PropTypes.bool,
/**
* The class name for the element, optional.
*/
className: PropTypes.string,
/**
* The component used for the link, optional.
*/
linkComponent: PropTypes.oneOfType([ PropTypes.string, PropTypes.func ]),
};

Expand Down
6 changes: 3 additions & 3 deletions packages/callout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"serve": "browser-sync tests --files \"tests/**/*.html, tests/**/*.css, tests/**/*.js\"",

"watch:js": "onchange \"src/js/*.js\" -- npm run build:js",
"watch:jsx": "onchange \"src/js/react.js\" \"tests/react/index.js\" -- npm run build",
"watch:jsx": "onchange \"src/react/*.js\" \"tests/react/index.js\" -- npm run build",
"watch:sass": "onchange \"src/sass/*.scss\" \"tests/site/test.scss\" -- npm run build",
"watch": "npm run build && npm-run-all --parallel serve watch:*"
},
Expand All @@ -52,11 +52,11 @@
"sass-versioning": true
},
"react": {
"path": "lib/js/react.js"
"path": "lib/react/react.js"
}
}
},
"main": "lib/js/react.es5.js",
"main": "lib/react/react.es5.js",
"dependencies": {
"@gov.au/pancake": "~1",
"@gov.au/pancake-sass": "~2",
Expand Down
83 changes: 83 additions & 0 deletions packages/callout/src/react/callout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*! [replace-name] v[replace-version] */
/***************************************************************************************************************************************************************
*
* Callout function
*
* Use callout to notify and alert users of important snippets of information.
*
**************************************************************************************************************************************************************/

import React from 'react';
import PropTypes from 'prop-types';


// The following line will be replaced automatically with generic imports for the ES5 pipeline.
// You can safely ignore this bit if you use this module with pancake
//
// [replace-imports]


/**
* Default callout
*
* @param {string} title - The title of the header
* @param {string} level - The tag level (<h1/> <h2/> etc), default: '1'
* @param {boolean} srOnlyTitle - Title is visible to screen readers only
* @param {boolean} dark - Add the dark variation class, optional
* @param {boolean} alt - Add the alt variation class, optional
* @param {string} children - Anything inside
* @param {string} className - An additional class, optional
* @param {object} attributeOptions - Any other attribute options
*/
export const AUcallout = ({ title, level, srOnlyTitle, dark, alt, description, children, className = '', ...attributeOptions }) => {
const HeadingTag = `h${ level }`;

return (
<section
className={ `au-callout ${ className }${ dark ? ' au-callout--dark' : '' }${ alt ? ' au-callout--alt' : '' }` }
{ ...attributeOptions }
>
<HeadingTag
children={ title }
className={ `au-callout__heading${ srOnlyTitle ? ' au-callout__heading--sronly' : '' }` }
/>
{ children }
</section>
)
};

AUcallout.propTypes = {
/**
* Title of the callout.
*/
title: PropTypes.string.isRequired,
/**
* The tag level (<h1/> <h2/> etc), default: '1'.
*/
level: PropTypes.number,
/**
* Make title screen reader visible.
*/
srOnlyTitle: PropTypes.bool,
/**
* A dark variation of the component.
*/
dark: PropTypes.bool,
/**
* A alternate variation of the component.
*/
alt: PropTypes.bool,
/**
* Anything inside.
*/
children: PropTypes.node.isRequired,
/**
* The class name for the element, optional.
*/
className: PropTypes.string,
};

AUcallout.defaultProps = {
level: 2,
srOnlyTitle: false,
};
Loading