Skip to content
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

Fix documentation playground react #1629

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ To suppress the internal validation of a component, you have to provide the `nov
Please note that using the `required` attribute in an Angular application could result in unfavourabe behaviour displaying the field as invalid even if there was no user interaction yet.
To avoid that it is suggested not to add the `required` attribute, but implement a custom validator for required fields instead (see `name` and `last-name` in the following code).
</Admonition>
<SourceCodePreview framework="angular" name="form-validation" examplesByName/>
<SourceCodePreview framework="angular" name="form-validation" examplesByName includeCssFile/>

</TabItem>
<TabItem value="react" label="React">
<Admonition type="tip" icon="๐Ÿ’ก" title="Just an example">
Using `react-form-hook` is just an example to demonstrate how validation could be done
within React. You can use any other validation library or write your own validation logic.
</Admonition>
<SourceCodePreview framework="react" name="form-validation" examplesByName/>
<SourceCodePreview framework="react" name="form-validation" examplesByName includeCssFile/>

</TabItem>
<TabItem value="vue" label="Vue">
<Admonition type="tip" icon="๐Ÿ’ก" title="Just an example">
Using `@vuelidate/core` is just an example to demonstrate how validation could be done
within Vue. You can use any other validation library or write your own validation logic.
</Admonition>
<SourceCodePreview framework="vue" name="form-validation" examplesByName/>
<SourceCodePreview framework="vue" name="form-validation" examplesByName includeCssFile/>

</TabItem>
</Tabs>
10 changes: 6 additions & 4 deletions packages/documentation/src/components/PlaygroundV2/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ export async function fetchSourceFilesByFileName(
files.map(async (file) => {
try {
const source = await fetchSource(
getLanguage(file) === 'css'
? `${path}/previews/styles/${file}`
: `${path}/previews/${frameworkPath}/${file}`
`${path}/previews/${frameworkPath}/${file}`
);

if (!source) {
Expand Down Expand Up @@ -198,7 +196,11 @@ export async function fetchSourceFilesFromExample(
}

if (includeCssFile) {
filesToFetch.push(`${exampleName}.css`);
if (framework === TargetFramework.REACT) {
filesToFetch.push(`${exampleName}.scoped.css`);
} else {
filesToFetch.push(`${exampleName}.css`);
}
}

return fetchSourceFilesByFileName(baseUrl, framework, filesToFetch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export async function fetchSourceForReact(baseUrl: string, name: string) {
snippets[`${name}.tsx`] = tsFile;

try {
const styleFile = await docusaurusFetch(`${baseUrl}/${name}.css`);
const styleFile = await docusaurusFetch(`${baseUrl}/${name}.scoped.css`);
if (styleFile) {
snippets[`./${name}.css`] = styleFile;
snippets[`./${name}.scoped.css`] = styleFile;
}
} catch (e) {}

Expand Down
Loading