Skip to content

Commit

Permalink
Merge pull request #5924 from veroglez/LPD-46156
Browse files Browse the repository at this point in the history
docs(clayui.com): LPD-46156 Add API documentation
  • Loading branch information
pat270 authored Jan 23, 2025
2 parents ec13b8b + 0b057ba commit 0777d79
Show file tree
Hide file tree
Showing 5 changed files with 568 additions and 411 deletions.
533 changes: 127 additions & 406 deletions clayui.com/static/sass-api/index.html

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions packages/clay-core/docs/api-language-picker.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: 'Language Picker'
description: 'A language picker is very similar to a dropdown visually but it let users select languages from the panel and then represent the selection in the button.'
mainTabURL: 'docs/components/language-picker.html'
---

## Language Picker

<div>[APITable "clay-core/src/language-picker/index.tsx"]</div>
298 changes: 298 additions & 0 deletions packages/clay-core/docs/language-picker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
/**
* SPDX-FileCopyrightText: © 2025 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: BSD-3-Clause
*/

import Editor from '$clayui.com/src/components/Editor';
import {LanguagePicker} from '@clayui/core';
import React from 'react';

const exampleImports = `import {LanguagePicker} from '@clayui/core';
import React from 'react';`;

const exampleCode = `const SelectLanguage = () => {
return (
<div style={{width: 'fit-content'}}>
<LanguagePicker locales={[
{
id: 'en_US',
label: 'en-US',
name: 'English (United States)',
symbol: 'en-us',
},
{
id: 'ar_SA',
label: 'ar-SA',
name: 'Arabic (Saudi Arabia)',
symbol: 'ar-sa',
},
{
id: 'ca_ES',
label: 'ca-ES',
name: 'Catalan (Spain)',
symbol: 'ca-es',
},
{
id: 'nl_NL',
label: 'nl-NL',
name: 'Dutch (Netherlands)',
symbol: 'nl-nl',
},
{
id: 'fi_FI',
label: 'fi-FI',
name: 'Finnish (Finland)',
symbol: 'fi-fi',
},
{
id: 'fr_FR',
label: 'fr-FR',
name: 'French (France)',
symbol: 'fr-fr',
},
{
id: 'de_DE',
label: 'de-DE',
name: 'German (Germany)',
symbol: 'de-de',
},
{
id: 'hu_HU',
label: 'hu-HU',
name: 'Hungarian (Hungary)',
symbol: 'hu-hu',
},
]} />
</div>
);
};
render(<SelectLanguage />)`;

const LanguagePickerExample = () => {
const scope = {LanguagePicker};

return <Editor code={exampleCode} imports={exampleImports} scope={scope} />;
};

const exampleLanguagesImports = `import {LanguagePicker} from '@clayui/core';
import React from 'react';`;

const exampleLanguagesCode = `const SelectLanguage = () => {
return (
<div style={{width: 'fit-content'}}>
<LanguagePicker locales={[
{
id: 'en_US',
label: 'en-US',
name: 'English (United States)',
symbol: 'en-us',
},
{
id: 'ar_SA',
label: 'ar-SA',
name: 'Arabic (Saudi Arabia)',
symbol: 'ar-sa',
},
{
id: 'ca_ES',
label: 'ca-ES',
name: 'Catalan (Spain)',
symbol: 'ca-es',
},
{
id: 'nl_NL',
label: 'nl-NL',
name: 'Dutch (Netherlands)',
symbol: 'nl-nl',
}
]} />
</div>
);
};
render(<SelectLanguage />)`;

const LanguagePickerLanguagesExample = () => {
const scope = {LanguagePicker};

return (
<Editor
code={exampleLanguagesCode}
imports={exampleLanguagesImports}
scope={scope}
/>
);
};

const exampleTranslationsImports = `import {LanguagePicker} from '@clayui/core';
import React from 'react';`;

const exampleTranslationsCode = `const SelectLanguage = () => {
const translations = {
'ca-ES': {total: 4, translated: 2},
'nl-NL': {total: 4, translated: 4},
};
return (
<div style={{width: 'fit-content'}}>
<LanguagePicker
locales={[
{
id: 'en_US',
label: 'en-US',
name: 'English (United States)',
symbol: 'en-us',
},
{
id: 'ar_SA',
label: 'ar-SA',
name: 'Arabic (Saudi Arabia)',
symbol: 'ar-sa',
},
{
id: 'ca_ES',
label: 'ca-ES',
name: 'Catalan (Spain)',
symbol: 'ca-es',
},
{
id: 'nl_NL',
label: 'nl-NL',
name: 'Dutch (Netherlands)',
symbol: 'nl-nl',
}
]}
translations={translations}
/>
</div>
);
};
render(<SelectLanguage />)`;

const LanguagePickerTranslationsExample = () => {
const scope = {LanguagePicker};

return (
<Editor
code={exampleTranslationsCode}
imports={exampleTranslationsImports}
scope={scope}
/>
);
};

const exampleSmallImports = `import {LanguagePicker} from '@clayui/core';
import React from 'react';`;

const exampleSmallCode = `const SelectLanguage = () => {
return (
<div style={{width: 'fit-content'}}>
<LanguagePicker
locales={[
{
id: 'en_US',
label: 'en-US',
name: 'English (United States)',
symbol: 'en-us',
},
{
id: 'ar_SA',
label: 'ar-SA',
name: 'Arabic (Saudi Arabia)',
symbol: 'ar-sa',
},
{
id: 'ca_ES',
label: 'ca-ES',
name: 'Catalan (Spain)',
symbol: 'ca-es',
},
{
id: 'nl_NL',
label: 'nl-NL',
name: 'Dutch (Netherlands)',
symbol: 'nl-nl',
}
]}
small
/>
</div>
);
};
render(<SelectLanguage />)`;

const LanguagePickerSmallExample = () => {
const scope = {LanguagePicker};

return (
<Editor
code={exampleSmallCode}
imports={exampleSmallImports}
scope={scope}
/>
);
};

const exampleOnlyIconImports = `import {LanguagePicker} from '@clayui/core';
import React from 'react';`;

const exampleOnlyIconCode = `const SelectLanguage = () => {
return (
<div style={{width: 'fit-content'}}>
<LanguagePicker
hideTriggerText
locales={[
{
id: 'en_US',
label: 'en-US',
name: 'English (United States)',
symbol: 'en-us',
},
{
id: 'ar_SA',
label: 'ar-SA',
name: 'Arabic (Saudi Arabia)',
symbol: 'ar-sa',
},
{
id: 'ca_ES',
label: 'ca-ES',
name: 'Catalan (Spain)',
symbol: 'ca-es',
},
{
id: 'nl_NL',
label: 'nl-NL',
name: 'Dutch (Netherlands)',
symbol: 'nl-nl',
}
]}
/>
</div>
);
};
render(<SelectLanguage />)`;

const LanguagePickerOnlyIconExample = () => {
const scope = {LanguagePicker};

return (
<Editor
code={exampleOnlyIconCode}
imports={exampleOnlyIconImports}
scope={scope}
/>
);
};

export {
LanguagePickerExample,
LanguagePickerLanguagesExample,
LanguagePickerOnlyIconExample,
LanguagePickerSmallExample,
LanguagePickerTranslationsExample,
};
Loading

0 comments on commit 0777d79

Please sign in to comment.