-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5924 from veroglez/LPD-46156
docs(clayui.com): LPD-46156 Add API documentation
- Loading branch information
Showing
5 changed files
with
568 additions
and
411 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,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> |
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,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, | ||
}; |
Oops, something went wrong.