Skip to content

Commit 2b6de0d

Browse files
committed
Add basic CodeBlock component
1 parent 83a81e7 commit 2b6de0d

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

content/github/getting-started-with-github/access-permissions-on-github.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ A repository owned by a user account has two permission levels: the *repository
1818

1919
### Organization accounts
2020
<!--react-->
21-
<BlueContent>
22-
{`var i;
23-
for (i = 0; i < cars.length; i++) {
24-
text += cars[i] + "<br>";
25-
}`}
26-
</BlueContent>
21+
<CodeBlock>
22+
{`var i;
23+
for (i = 0; i < cars.length; i++) {
24+
text += cars[i] + "<br>";
25+
}`}
26+
</CodeBlock>
2727
<!--end-react-->
2828

2929
Organization members can have *owner*{% if currentVersion == "free-pro-team@latest" %}, *billing manager*,{% endif %} or *member* roles. Owners have complete administrative access to your organization{% if currentVersion == "free-pro-team@latest" %}, while billing managers can manage billing settings{% endif %}. Member is the default role for everyone else. You can manage access permissions for multiple members at a time with teams. For more information, see:
@@ -32,8 +32,6 @@ Organization members can have *owner*{% if currentVersion == "free-pro-team@late
3232
- "[Repository permission levels for an organization](/articles/repository-permission-levels-for-an-organization)"
3333
- "[About teams](/articles/about-teams)"
3434

35-
<!--react--><BlueContent>More blue content!</BlueContent><!--end-react-->
36-
3735
<!--react--><RedContent>Red content!</RedContent><!--end-react-->
3836

3937
<!--react--><Timer /><!--end-react-->

javascripts/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import experiment from './experiment'
1616
import copyCode from './copy-code'
1717
import { fillCsrf } from './get-csrf'
1818
import initializeEvents from './events'
19-
import BlueContent from '../react/BlueContent'
19+
import CodeBlock from '../react/CodeBlock'
2020
import RedContent from '../react/RedContent'
2121
import Timer from '../react/Timer'
2222

@@ -40,7 +40,7 @@ document.addEventListener('DOMContentLoaded', async () => {
4040
})
4141

4242
module.export = {
43-
BlueContent,
43+
CodeBlock,
4444
RedContent,
4545
Timer
4646
}

lib/react-engine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const React = require('react')
33
const { renderToString } = require('react-dom/server')
44
const mdx = require('@mdx-js/mdx')
55
const { MDXProvider, mdx: createElement } = require('@mdx-js/react')
6-
const BlueContent = require('../dist/react/BlueContent')
6+
const CodeBlock = require('../dist/react/CodeBlock')
77
const RedContent = require('../dist/react/RedContent')
88
const Timer = require('../dist/react/Timer')
99

@@ -17,7 +17,7 @@ const transform = code =>
1717

1818
const renderReact = async componentStr => {
1919
let componentName
20-
if (componentStr.trim().startsWith('<BlueContent')) componentName = 'bluecontent'
20+
if (componentStr.trim().startsWith('<CodeBlock')) componentName = 'codeblock'
2121
if (componentStr.trim().startsWith('<RedContent')) componentName = 'redcontent'
2222
if (componentStr.trim().startsWith('<Timer')) componentName = 'timer'
2323

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
const React = require('react')
22
const ReactDOM = require('react-dom')
33

4-
const BlueContent = (props) => {
4+
const CodeBlock = (props) => {
55
return (
6-
<div style={{ color: 'blue' }}>
6+
<pre>
77
{props.children}
8-
{props.extra}
9-
</div>
8+
</pre>
109
)
1110
}
1211

1312
if (typeof window === 'undefined') {
1413
} else {
15-
const componentContainers = document.querySelectorAll('.react-component-bluecontent')
14+
const componentContainers = document.querySelectorAll('.react-component-codeblock')
1615

1716
for (const componentContainer of componentContainers) {
18-
ReactDOM.render(React.createElement(BlueContent, {}, componentContainer.children[0].innerText), componentContainer)
17+
ReactDOM.render(React.createElement(CodeBlock, {}, componentContainer.children[0].innerText), componentContainer)
1918
}
2019
}
2120

22-
module.exports = BlueContent
21+
module.exports = CodeBlock

0 commit comments

Comments
 (0)