Skip to content

Commit

Permalink
feat(@clayui/icon-selector): LPD-46157 Add new icon-selector componen…
Browse files Browse the repository at this point in the history
…t and it's imports
  • Loading branch information
ilzamcmed committed Jan 28, 2025
1 parent df4bdf9 commit e830590
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
63 changes: 63 additions & 0 deletions packages/clay-core/src/icon-selector/IconSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* SPDX-FileCopyrightText: © 2025 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: BSD-3-Clause
*/

import ClayButton from '@clayui/button';
import Input from '@clayui/form/src/Input';
import Icon from '@clayui/icon';
import React, {useState} from 'react';

import DropdownSelector from './DropdownSelector';

export function IconSelector() {
const [selectedIcon, setSelectedIcon] = useState<string>('');

const handleIconSelect = (icon: string) => {
setSelectedIcon(icon);
};

const handleClearSelection = () => {
setSelectedIcon('');
};

return (
<>
{selectedIcon ? (
<div className="selected-icon-container">
<Input.Group stacked>
<ClayButton
aria-label={selectedIcon}
displayType="secondary"
>
<Icon symbol={selectedIcon} />
</ClayButton>

<Input
readOnly
value={
selectedIcon.charAt(0).toUpperCase() +
selectedIcon.slice(1)
}
/>
</Input.Group>

<DropdownSelector
buttonWithIcon
handleIconSelect={handleIconSelect}
/>

<ClayButton
aria-label="delete icon"
displayType="secondary"
onClick={handleClearSelection}
>
<Icon symbol="trash" />
</ClayButton>
</div>
) : (
<DropdownSelector handleIconSelect={handleIconSelect} />
)}
</>
);
}
6 changes: 6 additions & 0 deletions packages/clay-core/src/icon-selector/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* SPDX-FileCopyrightText: © 2022 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: BSD-3-Clause
*/

export {IconSelector} from './IconSelector';

0 comments on commit e830590

Please sign in to comment.