-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
91 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
import { withCopy, CopyType } from "./configureCopy"; | ||
|
||
const BodySection = ({ copy }: { copy: CopyType }) => { | ||
return <div>{copy.body}</div>; | ||
}; | ||
export default withCopy(BodySection); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react"; | ||
import { CopyfulProvider, getCopySomehow } from "./configureCopy"; | ||
import HeaderSection from "./HeaderSection"; | ||
import BodySection from "./BodySection"; | ||
|
||
function App() { | ||
return ( | ||
<CopyfulProvider copy={getCopySomehow("en-us")}> | ||
<HeaderSection />{/* Example Using Hooks */} | ||
<BodySection />{/* Example Using HOC */} | ||
</CopyfulProvider> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
import { useCopy } from "./configureCopy"; | ||
|
||
const HeaderSection = () => { | ||
const context = { | ||
someNumber: 4815162342, | ||
someString: "Hello World!", | ||
}; | ||
const { | ||
title, | ||
subtitle, | ||
nested: { dynamicValues }, | ||
} = useCopy(context).header; | ||
|
||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<h1>{title}</h1> | ||
<h2>{subtitle}</h2> | ||
<p>{dynamicValues}</p> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default HeaderSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createCopyful } from "./Copyful"; | ||
import copy from "./copy.json"; | ||
|
||
export interface LocalesType { | ||
[key: string]: CopyType; | ||
} | ||
export interface CopyType { | ||
header: { | ||
title: string; | ||
subtitle: string; | ||
nested: { | ||
dynamicValues: string; | ||
}; | ||
}; | ||
body: string; | ||
} | ||
|
||
|
||
export const getCopySomehow = (locale: string) => { | ||
return (copy as LocalesType)[locale]; | ||
}; | ||
|
||
export const { CopyfulProvider, useCopy, withCopy } = createCopyful( | ||
getCopySomehow("1337") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import App from "./App"; | ||
import Example from "./Example"; | ||
|
||
ReactDOM.render(<App />, document.getElementById("root")); | ||
ReactDOM.render(<Example />, document.getElementById("root")); |