Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial basic footer #1

Merged
merged 5 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage
dist
node_modules
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage
dist
node_modules
temp

.idea/

src/i18n/transifex_input.json
temp/babel-plugin-react-intl
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
.eslintcache
node_modules
npm-debug.log
.travis.yml
.babelrc
.eslintignore
.eslintrc.json
commitlint.config.js
webpack.config.js
**.test.js
**tests
27 changes: 27 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"branch": "master",
"tagFormat": "v${version}",
"verifyConditions": [
"@semantic-release/npm",
{
"path": "@semantic-release/github",
"assets": {
"path": "dist/*"
}
}
],
"analyzeCommits": "@semantic-release/commit-analyzer",
"generateNotes": "@semantic-release/release-notes-generator",
"prepare": "@semantic-release/npm",
"publish": [
"@semantic-release/npm",
{
"path": "@semantic-release/github",
"assets": {
"path": "dist/*"
}
}
],
"success": [],
"fail": []
}
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: node_js
node_js: 12
install:
- npm install
script:
- npm run lint
- npm run i18n_extract
- npm run test
- npm run build
after_success:
- npx semantic-release
- npm run coveralls
abutterworth marked this conversation as resolved.
Show resolved Hide resolved
env:
global:
# GH_TOKEN
secure: "rsp0BAOaf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mj4XNQbz6AL2xarp3y63RwpfTsXJxlqSMqw2wSN8vO9+ToJBEoiND4dgP3LDUvQCT+A15crBrQtXoONoNQruDmCh0+sbAu+/NEyjBwJuJr4oDSQNB221TtXpuLA1DeSyyRfw0vxKgU3M8IFSm89kjvU/Nn+qj/YLzqrC9RgXifhTLcBSgAHEiezlzagFWPMXrA4fpl5CnShCzF+cxk+El76wqwUTxckpHlGxsm9hDKLiL4Ce7oR/X7Z0PJTZjBn/cvkAdysMPoIq/8EcnTc0pYtw/8jCe2tVa8K0e6zevLt9U="
8 changes: 8 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[main]
host = https://www.transifex.com

[edx-platform.frontend-component-footer-edx]
file_filter = src/i18n/messages/<lang>.json
source_file = src/i18n/transifex_input.json
source_lang = en
type = KEYVALUEJSON
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
transifex_resource = frontend-component-footer-edx
transifex_langs = "ar,fr,es_419,zh_CN"

transifex_utils = ./node_modules/.bin/transifex-utils.js
i18n = ./src/i18n
transifex_input = $(i18n)/transifex_input.json
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/translation/en/strings/
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/source/

# This directory must match .babelrc .
transifex_temp = ./temp/babel-plugin-react-intl

build:
rm -rf ./dist
./node_modules/.bin/fedx-scripts babel src --out-dir dist --source-maps --ignore **/*.test.jsx,**/__mocks__,**/__snapshots__,**/setupTest.js --copy-files
@# --copy-files will bring in everything else that wasn't processed by babel. Remove what we don't want.
@rm -rf dist/**/*.test.jsx
@rm -rf dist/**/__snapshots__
@rm -rf dist/__mocks__

requirements:
npm install

i18n.extract:
# Pulling display strings from .jsx files into .json files...
rm -rf $(transifex_temp)
npm run-script i18n_extract

i18n.concat:
# Gathering JSON messages into one file...
$(transifex_utils) $(transifex_temp) $(transifex_input)

extract_translations: | requirements i18n.extract i18n.concat

# Despite the name, we actually need this target to detect changes in the incoming translated message files as well.
detect_changed_source_translations:
# Checking for changed translations...
git diff --exit-code $(i18n)

# Pushes translations to Transifex. You must run make extract_translations first.
push_translations:
# Pushing strings to Transifex...
tx push -s
# Fetching hashes from Transifex...
./node_modules/reactifex/bash_scripts/get_hashed_strings.sh $(tx_url1)
# Writing out comments to file...
$(transifex_utils) $(transifex_temp) --comments
# Pushing comments to Transifex...
./node_modules/reactifex/bash_scripts/put_comments.sh $(tx_url2)

# Pulls translations from Transifex.
pull_translations:
tx pull -f --mode reviewed --language=$(transifex_langs)

# This target is used by Travis.
validate-no-uncommitted-package-lock-changes:
# Checking for package-lock.json changes...
git diff --exit-code package-lock.json
1 change: 0 additions & 1 deletion README.md

This file was deleted.

64 changes: 64 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
frontend-component-footer-edx
=========================

|Build Status| |Coveralls| |npm_version| |npm_downloads| |license|
|semantic-release|

frontend-component-footer-edx is a library containing a site footer
component for use when building edX frontend applications.

Usage
-----

To install frontend-component-footer-edx into your project::

npm i --save @edx/frontend-component-footer-edx

Component Usage::

import Footer from '@edx/frontend-component-footer-edx';
import footerMessages from '@edx/frontend-component-footer-edx/src/i18n/index';

...

<Footer
handleAllTrackEvents={(eventName, properties) => {/* track click event */}}
onLanguageSelected={(languageCode) => {/* set language */}}
supportedLanguages={[
{ label: 'English', value: 'en'},
{ label: 'Español', value: 'es' },
]}
/>

- handleAllTrackEvents (required)
- onLanguageSelected (optional)
- supportedLanguages (optional)

Requirements
------------

This component uses ``@edx/frontend-i18n``. Any containing app must provide ``@edx/frontend-i18n`` as a peer dependency, and be wrapped inside an ``IntlProvider`` element, whether or not your consuming application is actually localized. For a basic default locale (English) version, follow the ``IntlProvider`` example in the sample application in `src/index.jsx <src/index.jsx>`__.

Development
-----------

Start the dev server::

npm i && npm start

Build the component::

npm run build

.. |Build Status| image:: https://api.travis-ci.org/edx/frontend-component-footer-edx.svg?branch=master
:target: https://travis-ci.org/edx/frontend-component-footer-edx
.. |Coveralls| image:: https://img.shields.io/coveralls/edx/frontend-component-footer-edx.svg?branch=master
:target: https://coveralls.io/github/edx/frontend-component-footer-edx
.. |npm_version| image:: https://img.shields.io/npm/v/@edx/frontend-component-footer-edx.svg
:target: @edx/frontend-component-footer-edx
.. |npm_downloads| image:: https://img.shields.io/npm/dt/@edx/frontend-component-footer-edx.svg
:target: @edx/frontend-component-footer-edx
.. |license| image:: https://img.shields.io/npm/l/@edx/frontend-component-footer-edx.svg
:target: @edx/frontend-component-footer-edx
.. |semantic-release| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
:target: https://github.com/semantic-release/semantic-release
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub';
35 changes: 35 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// These preset packages are included by frontend-build.
// TODO: Add to frontend-build and leverage that config.
module.exports = {
presets: [
[
'@babel/preset-env',
{
modules: false,
},
],
'@babel/preset-react',
],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
],
env: {
i18n: {
plugins: [
[
'react-intl',
{
messagesDir: './temp/babel-plugin-react-intl',
moduleSourceName: '@edx/frontend-i18n',
},
],
],
},
test: {
presets: [
'@babel/preset-env',
],
},
},
};
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-angular'],
};
25 changes: 25 additions & 0 deletions example/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { render } from 'react-dom';
import { IntlProvider } from '@edx/frontend-i18n';

import './index.scss';
import Footer from '../src';

const App = () => (
<div>
<IntlProvider locale="en">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, you should be able to use frontend-base in this example app, like the header repos. (I don't feel strongly)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figure this is just as easy.

<Footer
/* eslint-disable-next-line no-unused-vars */
handleAllTrackEvents={(eventName, properties) => {}}
/* eslint-disable-next-line no-unused-vars */
onLanguageSelected={(languageCode) => {}}
supportedLanguages={[
{ label: 'English', value: 'en' },
{ label: 'Español', value: 'es' },
]}
/>
</IntlProvider>
</div>
);

render(<App />, document.getElementById('root'));
3 changes: 3 additions & 0 deletions example/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import "~@edx/paragon/scss/edx/theme.scss";
@import "~@edx/paragon/scss/edx/fonts.scss";
@import '../src/footer.scss';
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { createConfig } = require('@edx/frontend-build');

module.exports = createConfig('jest', {
setupFiles: [
'<rootDir>/src/setupTest.js',
],
});
8 changes: 8 additions & 0 deletions openedx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# openedx.yaml

---
owner: edx/fedx-team
tags:
- library
- component
- react
Loading