Skip to content

Commit

Permalink
Copy over some repo setup stuff and example packages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkilgour committed Sep 26, 2019
1 parent a842737 commit d79be65
Show file tree
Hide file tree
Showing 84 changed files with 3,941 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
root = true

[*]
end_of_line = lf
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.json]
insert_final_newline = false

[package.json]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/__tests__/*
**/coverage/*
**/node_modules/*
**/docs/*
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": [
"@springernature/eslint-config",
"@springernature/eslint-config/node",
"@springernature/eslint-config/jest"
],
"parserOptions": {
"ecmaVersion": 9
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ typings/

# next.js build output
.next

# mac
.DS_Store
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/dubnium
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# Build matrix
language: node_js

# Environment variables
env:
global:
- CHANGED_FILES=$(git diff --name-only $TRAVIS_COMMIT_RANGE)

# cache the node modules
cache:
directories:
- node_modules
- "$HOME/.npm"

# Restrict builds on branches
branches:
only:
- master
- /^\d+\.\d+\.\d+$/

# build notification
notifications:
email:
- [email protected]
slack:
secure: BUpGvVA99nm+6j/ju8WBoHmQ6P3aC2V29zx/RW4uynisjzl4YYCrk3dCYA7gG2OkRHz50+J3d4bqV8kbpUc9XW90n1NjvFoq5SFYrgasp/TLETUVmSfJwgr3D+aEW6xWy7DvzsfIGdw4CHd4Ih35BP3QRxnRgLXlJtOrZ2BH1Wz3xc3yY4v2zMp/B5Fo+pU86QGUIhRSNk70dJYON3iuqH6VJAlkIvIBnUwYCDGWtZQVsfLXwfvZ3nZMWIGAzGIyAtjWrrUY1+RIvZlVInxidA+z19Z3kZrcUaTkAQL73H55ewx7+rftrdWZczM7Tv0G2/rreQuiLYZ+2CLoq0H5uDdXsJxv1LE5xCrrKjMmX7mWGZKQGHUR5IIaBcwmeYeKNbKzrH7yS6b4PVPnp0UegL/j0Oyt2zX8UZRgIPk1CbnpkZF0BgXtEKy40MP3Pq0bwXITecrSRdWMgSwoCEjw7FEUHBh7ts0nSX/3qpf525TtvHAXoWV3kUt9s8ExScVzMXzsA4ph3zHxkgSm0K13Z/xWv384gABJ6rrqnGylqhjpIpXfJG8z0csdccj5E1tFG0kJ12Amepr96K4dqDelzHLuuepnuogdGlnrdfYokS6Rz+J5/1ta/jkpLmtd8e+wjJKk4pjsY0hFObM01gQbHJsTd5ws7ciU7wg++HJkXoo=

# Build script
script:
- 'lerna bootstrap --hoist && npm run build:ci'

# Auto-publish after script
after_success:
- 'if [[ $TRAVIS_PULL_REQUEST = "false" ]]; then PUBLISH_PACKAGE=true; else PUBLISH_PACKAGE=false; fi'
- 'echo "Pull Request: $TRAVIS_PULL_REQUEST" && echo "Node: $TRAVIS_NODE_VERSION" && echo "Publish? $PUBLISH_PACKAGE"'
- 'if [ $PUBLISH_PACKAGE = "true" ]; then npm run publish; fi'
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Contributing to frontend-toolkit-utilities

When contributing to an existing package, or building a new one, work should:

- Always be done in a branch
- Always follow the best practices in the [front-end playbook](https://github.com/springernature/frontend-playbook/)
- Always involve updating or adding to the relevant parts of the documentation
- Always be linted
- **May** include any versioning information (see separate [versioning guidelines](#versioning))
- If this is a new package version as `0.0.0` in the `package.json` to stop auto-publication
- Always be submitted via a pull request in the [`#frontend-pr`](https://springernature.slack.com/messages/C0GJK53TQ/) slack room

### Pull requests

- Good pull requests - patches, improvements, new features - should remain focused in scope and avoid containing unrelated commits. You should follow the guidelines in the [front-end playbook](https://github.com/springernature/frontend-playbook/blob/master/practices/code-review.md)
- Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage)
- Merging pull requests should be done via [squash and merge](https://help.github.com/articles/about-pull-request-merges/#squash-and-merge-your-pull-request-commits)
- Once your pull request has been merged back to the master branch, you can follow the [versioning guidelines](#versioning) below to publish your changes. **Note**: you do not have to create a new version after every merge. Related merges can be bundled into one new version

### Linting

Whenever you make changes to this repo, you should run the linter locally before you commit your work. The following command is available to do this:

```
$ npm run lint
```

### Versioning

All packages are versioned individually using [semver](http://semver.org/). You should read through the semver documentation, and the guidelines in the [front-end playbook](https://github.com/springernature/frontend-playbook/blob/master/practices/semver.md).

To publish a new version of a package, or to publish a new package:

1. Version commits can be managed in their own PR or as part of your package update PR
2. Increment either the major, minor, or patch version in the relevant `package.json`. If you're unsure which, have a chat about it or re-read the semver docs
* Development versions of a package should start at version `0.1.0` as per the [semver documentation](https://semver.org/#spec-item-4)
3. Add an entry to the relevant `HISTORY.md` file outlining the changes in the new version. Take your time, this log should be useful to developers – it should help them make decisions about whether they can upgrade. If this file is not updated then travis will fail the build.
4. (Make sure you only publish one package at a time)
6. Code review your pull request and merge
7. The build system will automatically publish your new version based on the `package.json` version

### Vulnerability detection

After publication of a new package, it needs to be added to Snyk so that the dependencies can be tracked. More information on Snyk can be found in the [front-end playbook](https://github.com/springernature/frontend-playbook/blob/master/practices/managing-node-projects.md#dependency-management-tools)

To add a new package to Snyk:

1. Make sure that you are authorised via your GutHub account
2. Log into Snyk and switch to the `springernature` organisation
3. Switch to the `Projects` tab and search for `frontend-toolkit-utilities`
4. Click the + icon to add your new package
5. Add the target path to the `package.json` file e.g. `packages/my-package/package.json`
20 changes: 20 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
A note on this file & monorepos
https://babeljs.io/docs/en/config-files#monorepos
*/

module.exports = function (api) {
api.cache(true);

const presets = ['@babel/preset-env'];
const plugins = [];

return {
presets,
plugins,
babelrcRoots: [
'.',
'packages/*'
]
};
};
14 changes: 14 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"command": {
"publish": {
"ignoreChanges": [
"ignored-file",
"*.md"
]
}
},
"packages": [
"toolkits/**/packages/*"
],
"version": "independent"
}
63 changes: 63 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "frontend-toolkits",
"description": "Frontend Component Toolkits for the Elements Design System",
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/springernature/frontend-toolkits.git"
},
"keywords": [
"frontend",
"fed",
"toolkits",
"elements",
"components"
],
"author": "Springer Nature",
"scripts": {
"build": "npm run lint && npm run test && npm run validate",
"build:ci": "npm run lint && npm run test:ci && npm run validate -- -n",
"create": "sn-package-create",
"lint": "npm run lint:js",
"lint:js": "eslint .",
"publish": "sn-package-publish",
"test": "jest --colors --coverage --passWithNoTests",
"test:ci": "jest --passWithNoTests --runInBand",
"validate": "sn-package-validate"
},
"bugs": {
"url": "https://github.com/springernature/frontend-toolkits/issues"
},
"homepage": "https://github.com/springernature/frontend-toolkits#readme",
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.5.0",
"@babel/preset-env": "^7.6.0",
"@babel/runtime": "^7.5.4",
"@springernature/eslint-config": "^2.1.1",
"@springernature/frontend-package-manager": "^3.0.0",
"eslint": "^5.16.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^21.27.2",
"eslint-plugin-no-use-extend-native": "^0.3.12",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-unicorn": "^4.0.3",
"jest": "^24.9.0",
"lerna": "^3.16.4"
},
"jest": {
"testURL": "http://localhost/",
"modulePaths": [
"<rootDir>/"
],
"verbose": true,
"testRegex": "__tests__/.*\\.js$",
"collectCoverageFrom": [
"toolkits/**/packages/**/*.js"
],
"coveragePathIgnorePatterns": [
"docs/"
]
}
}
18 changes: 18 additions & 0 deletions toolkits/global/packages/global-box/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# History

## 3.0.0 (2019-03-06)
* Update naming convention
* Add `.hbs` templates

## 2.0.0 (2018-05-17)
* Convert to a component

## 1.0.1 (2017-07-12)
* Minor bump to mask unpublished v1.0.0

## 1.0.0 (2017-06-01)
* Matches folder structure with SNCSS pattern

## 0.0.1 (2017-05-31)
* Simple box pattern with default skin
* standard and circular versions
47 changes: 47 additions & 0 deletions toolkits/global/packages/global-box/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
**_THIS IS AN EXAMPLE, NOT FOR PRODUCTION USE_**

# CSS box component

Simple box component. Import each `scss` file into the respective level in your application.

To brand this component either totally replace the settings level in your app, or include your own settings file _before_ this one if you want to keep some of the defaults.

## Examples

### HTML
```html
<!-- standard box -->
<div class="c-box">box content</div>

<!-- circular box -->
<div class="c-box c-box--circle">box content</div>
```

### Handlebars
```hbs
<!-- standard box -->
{{#> box }}
Add content here
Can even be another partial
{{/box}}
<!-- circular box -->
{{#> circle }}
Add content here
Can even be another partial
{{/circle}}
```

### @mixin
```scss
// Standard box
.class-name {
@include global-box;
}

// Circular box
.class-name {
@include global-box;
@include global-box--circle;
}
```
11 changes: 11 additions & 0 deletions toolkits/global/packages/global-box/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@springernature/global-box",
"version": "3.0.0",
"license": "MIT",
"description": "css box component",
"keywords": [
"css",
"component"
],
"author": "Alex Kilgour"
}
10 changes: 10 additions & 0 deletions toolkits/global/packages/global-box/scss/10-settings/_box.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @springernature/global-box
* Default skin settings
* Replace these in your application
*
*/
$box--padding: 12px;
$box--border-color: #000;
$box--background-color: #fff;
$box--circle-diameter: 3em;
30 changes: 30 additions & 0 deletions toolkits/global/packages/global-box/scss/30-mixins/_box.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @springernature/global-box
* Standard box
*
*/
@mixin box (
$padding: $box--padding,
$border: $box--border-color,
$background: $box--background-color
) {
border: 1px solid #{$border};
padding: #{$padding};
background-color: #{$background};
}

/**
* @springernature/global-box
* Circular box
*
*/
@mixin box--circle (
$diameter: $box--circle-diameter
) {
padding: 0;
border-radius: 50%;
height: #{$diameter};
width: #{$diameter};
line-height: calc(#{$diameter} - 2px);
text-align: center;
}
15 changes: 15 additions & 0 deletions toolkits/global/packages/global-box/scss/50-components/_box.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @springernature/global-box
* A container with 4 sides
*
*/

.c-box {
@include box;

// Circular box
// A container with no corners
&--circle {
@include box--circle;
}
}
3 changes: 3 additions & 0 deletions toolkits/global/packages/global-box/view/box.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="c-box">
{{> @partial-block }}
</div>
3 changes: 3 additions & 0 deletions toolkits/global/packages/global-box/view/circle.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="c-box c-box--circle">
{{> @partial-block }}
</div>
Loading

0 comments on commit d79be65

Please sign in to comment.