-
Notifications
You must be signed in to change notification settings - Fork 85
docs: add react component docs #117
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fba51a2
docs: add react component docs
Nemikolh 884ff68
Apply suggestions from code review
Nemikolh a517447
fix: add COEP, COOP headers to docs
Nemikolh fc6c0da
fix: build issue on cloudflare
Nemikolh 2a1be0c
Merge branch 'main' into joan/react-comp-docs
Nemikolh dc0171f
fix: start servor as soon as the shell is ready
Nemikolh 977200f
fix(docs): css issues
Nemikolh 45b9326
fix: cimprove Terminal docs
Nemikolh 78fac0f
Merge branch 'main' into joan/react-comp-docs
Nemikolh 1f5bfe8
Apply suggestions from code review
Nemikolh bb6ceca
fix: code review
Nemikolh b718027
fix: add link
Nemikolh 3626180
fix: code review and css issue with helper to hide visual bug
Nemikolh da5da7d
fix: css issues found during review
Nemikolh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
27 changes: 27 additions & 0 deletions
27
docs/tutorialkit.dev/src/components/react-examples/Example.astro
This file contains hidden or 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,27 @@ | ||
--- | ||
import { classNames } from '@tutorialkit/components-react'; | ||
|
||
interface Props { | ||
className?: string; | ||
previewClassName?: string; | ||
} | ||
|
||
const { className, previewClassName } = Astro.props; | ||
--- | ||
|
||
<div class={classNames('not-content react-example overflow-hidden', className)}> | ||
<div | ||
class={classNames( | ||
'border border-[var(--ec-brdCol)] border-b-transparent border-solid rounded-t overflow-y-auto', | ||
previewClassName, | ||
)} | ||
> | ||
<slot name="preview" /> | ||
</div> | ||
|
||
<slot name="code" /> | ||
</div> | ||
<script> | ||
import 'uno.css'; | ||
import './theme.css'; | ||
</script> |
52 changes: 52 additions & 0 deletions
52
docs/tutorialkit.dev/src/components/react-examples/ExampleCodeMirrorEditor.tsx
This file contains hidden or 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,52 @@ | ||
import type { EditorDocument, EditorUpdate, ScrollPosition } from '@tutorialkit/components-react/core'; | ||
import CodeMirrorEditor from '@tutorialkit/components-react/core/CodeMirrorEditor'; | ||
import { useState } from 'react'; | ||
import { useTheme } from './hooks/useTheme'; | ||
|
||
export default function ExampleCodeMirrorEditor() { | ||
const { document, theme, onChange, onScroll } = useEditorDocument(); | ||
|
||
return ( | ||
<CodeMirrorEditor | ||
theme={theme} | ||
doc={document} | ||
onChange={onChange} | ||
onScroll={onScroll} | ||
debounceChange={500} | ||
debounceScroll={500} | ||
className="h-full text-sm" | ||
/> | ||
); | ||
} | ||
|
||
function useEditorDocument() { | ||
const theme = useTheme(); | ||
const [document, setDocument] = useState<EditorDocument>(DEFAULT_DOCUMENT); | ||
Nemikolh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function onChange({ content }: EditorUpdate) { | ||
setDocument((prev) => ({ | ||
...prev, | ||
value: content, | ||
})); | ||
} | ||
|
||
function onScroll(scroll: ScrollPosition) { | ||
setDocument((prev) => ({ | ||
...prev, | ||
scroll, | ||
})); | ||
} | ||
|
||
return { | ||
theme, | ||
document, | ||
onChange, | ||
onScroll, | ||
}; | ||
} | ||
|
||
const DEFAULT_DOCUMENT: EditorDocument = { | ||
filePath: 'index.js', | ||
loading: false, | ||
value: 'function hello() {\n console.log("Hello, world!");\n}\n\nhello();', | ||
}; |
26 changes: 26 additions & 0 deletions
26
docs/tutorialkit.dev/src/components/react-examples/ExampleFileTree.tsx
This file contains hidden or 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 { useState } from 'react'; | ||
import FileTree from '@tutorialkit/components-react/core/FileTree'; | ||
|
||
export default function ExampleFileTree() { | ||
const [selectedFile, setSelectedFile] = useState(FILES[0]); | ||
|
||
return ( | ||
<FileTree | ||
files={FILES} | ||
hideRoot | ||
className="" | ||
Nemikolh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
hiddenFiles={['package-lock.json']} | ||
selectedFile={selectedFile} | ||
onFileSelect={setSelectedFile} | ||
/> | ||
); | ||
} | ||
|
||
const FILES = [ | ||
'/src/index.js', | ||
'/src/index.html', | ||
'/src/assets/logo.svg', | ||
'/package-lock.json', | ||
'/package.json', | ||
'/vite.config.js', | ||
]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.