Skip to content

Commit

Permalink
example project with typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
joaogsleite committed Jan 30, 2020
1 parent c559bc3 commit 349aae9
Show file tree
Hide file tree
Showing 22 changed files with 331 additions and 15,546 deletions.
4 changes: 3 additions & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
Expand Down
2,207 changes: 11 additions & 2,196 deletions example/README.md

Large diffs are not rendered by default.

13,271 changes: 0 additions & 13,271 deletions example/package-lock.json

This file was deleted.

24 changes: 17 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{
"name": "example",
"name": "react-multi-lang-example",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-multi-lang": "file:..",
"react-scripts": "^3.0.1"
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.12.26",
"@types/react": "^16.9.19",
"@types/react-dom": "^16.9.5",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0",
"typescript": "^3.7.5",
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand All @@ -25,5 +35,5 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
}
23 changes: 13 additions & 10 deletions example/public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand All @@ -22,9 +27,7 @@
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
Expand Down
Binary file added example/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion example/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "./index.html",
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
Expand Down
2 changes: 2 additions & 0 deletions example/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
36 changes: 23 additions & 13 deletions example/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,36 @@
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
height: 40vmin;
pointer-events: none;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-title {
font-size: 1.5em;
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-intro {
font-size: large;
.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
31 changes: 0 additions & 31 deletions example/src/App.js

This file was deleted.

9 changes: 9 additions & 0 deletions example/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
29 changes: 29 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { useTranslation, setLanguage, getLanguage } from 'react-multi-lang'

const App: React.FC = () => {

const t = useTranslation()

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">
{t('home.Title', {param: 'react'})}
</h1>
</header>
<p className="App-intro">
To change language just press the buttons beneath
</p>
<div>Selected lang <b>{getLanguage()}</b></div>
<br/>
<button onClick={() => setLanguage('pt')}>PT</button>
<button onClick={() => setLanguage('en')}>EN</button>
</div>
)
}

export default App;
12 changes: 10 additions & 2 deletions example/src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
12 changes: 0 additions & 12 deletions example/src/index.js

This file was deleted.

21 changes: 21 additions & 0 deletions example/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';


import { setDefaultTranslations, setDefaultLanguage } from 'react-multi-lang'
import pt from './translations/pt.json'
import en from './translations/en.json'

setDefaultTranslations({pt, en})
setDefaultLanguage('pt')


ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
1 change: 1 addition & 0 deletions example/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
Loading

0 comments on commit 349aae9

Please sign in to comment.