Skip to content

Instantly share code, notes, and snippets.

View weianofsteel's full-sized avatar

Weian weianofsteel

View GitHub Profile
npm install -S react-draft-wysiwyg
@weianofsteel
weianofsteel / Scroll up button
Created December 4, 2020 10:03
Scroll up button
import React from 'react';
import Button from '@material-ui/core/Button';
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
class ScrollUpButton extends React.Component {
constructor(props) {
super(props);
this.state = {
scrollC: 0
};
@weianofsteel
weianofsteel / npm publish package.json
Created December 4, 2020 10:05
npm publish package.json
{
"name": "react-scroll-up-btn",
"version": "1.0.3",
"description": "A simple scroll up button built with react",
"main": "./lib/ScrollUpButton.js",
"repository": {
"type": "git",
"url" : "https://github.com/weianofsteel/react-scroll-up-button"
},
"keywords": [
@weianofsteel
weianofsteel / ScrollUpBtn config
Created December 4, 2020 10:16
ScrollUpBtn config
const path = require('path');
module.exports = {
mode: 'production',
entry: './src/ScrollUpButton.js',
output: {
path: path.resolve('lib'),
filename: 'ScrollUpButton.js',
libraryTarget: 'commonjs2',
},
@weianofsteel
weianofsteel / ScrollUpBtn babelrc
Created December 4, 2020 10:17
ScrollUpBtn babelrc
{
"presets": [
"react",
"env",
"stage-0"
]
}
@weianofsteel
weianofsteel / i18n.js
Last active April 17, 2021 08:10
NextI18Next(i18n.js)
const NextI18Next = require('next-i18next').default
const localeSubpaths = require('next/config').default().publicRuntimeConfig
const path = require('path')
module.exports = new NextI18Next({
defaultLanguage:'en',
otherLanguages: ['zhHant', 'fr', 'es'],
localeSubpaths:{
zhHant:'cn',
fr: 'fr',
@weianofsteel
weianofsteel / i18n without localeSubpaths
Last active April 17, 2021 10:02
i18n without localeSubpaths
const NextI18Next = require('next-i18next').default
const localeSubpaths = require('next/config').default().publicRuntimeConfig
const path = require('path')
module.exports = new NextI18Next({
defaultLanguage:'en',
otherLanguages: ['zhHant', 'fr', 'es'],
localePath: path.resolve('./public/static/locales')
})
@weianofsteel
weianofsteel / _app.js
Created February 23, 2021 10:36
_app.js
import App from 'next/app'
import React from 'react';
import Head from 'next/head'
import { appWithTranslation } from '../i18n'
import '../css/main.css'
const MyApp = ({ Component, pageProps }) => {
return(
<React.Fragment>
@weianofsteel
weianofsteel / index.js
Last active April 17, 2021 08:53
index.js
import React from 'react'
import Sample from '../../component/Sample'
import { withTranslation } from '../../i18n'
import PropTypes from 'prop-types'
const SamplePage = ({t}) => {
return(
<Sample/>
)
}
@weianofsteel
weianofsteel / Sample.js
Last active February 23, 2021 15:21
Sample.js
import React from 'react'
import { i18n, withTranslation } from '../i18n'
import PropTypes from 'prop-types'
import TranslateIcon from '@material-ui/icons/Translate'
import { makeStyles } from '@material-ui/core/styles'
import MenuItem from '@material-ui/core/MenuItem';
import FormControl from '@material-ui/core/FormControl';
import Select from '@material-ui/core/Select';
import Grid from '@material-ui/core/Grid'