Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Display all exemplar files * Only show header if there's multiple files * Fix failing tests * Rename GitFile to MentoringSessionExemplarFile * Use test_helper * Inline exemplar files list Co-authored-by: Jeremy Walker <jez.walker@gmail.com>
- Loading branch information
1 parent
aacf716
commit c319e73
Showing
22 changed files
with
269 additions
and
54 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 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
44 changes: 44 additions & 0 deletions
44
app/javascript/components/mentoring/session/guidance/ExemplarFilesList.tsx
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,44 @@ | ||
import React from 'react' | ||
import { MentoringSessionExemplarFile } from '../../../types' | ||
|
||
export type Props = { | ||
files: readonly MentoringSessionExemplarFile[] | ||
language: string | ||
} | ||
|
||
export const ExemplarFilesList = ({ files, language }: Props): JSX.Element => { | ||
return ( | ||
<React.Fragment> | ||
{files.map((file) => ( | ||
<ExemplarFile key={file.filename}> | ||
{files.length > 1 ? ( | ||
<ExemplarFile.Header filename={file.filename} /> | ||
) : null} | ||
<ExemplarFile.Content content={file.content} language={language} /> | ||
</ExemplarFile> | ||
))} | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
const ExemplarFile = ({ children }: { children?: React.ReactNode }) => { | ||
return <div className="exemplar-files">{children}</div> | ||
} | ||
|
||
ExemplarFile.Header = ({ filename }: { filename: string }) => { | ||
return <div className="filename">{filename}</div> | ||
} | ||
|
||
ExemplarFile.Content = ({ | ||
content, | ||
language, | ||
}: { | ||
content: string | ||
language: string | ||
}) => { | ||
return ( | ||
<pre className="overflow-auto"> | ||
<code className={language}>{content}</code> | ||
</pre> | ||
) | ||
} |
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 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
Oops, something went wrong.