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

utils: add dropdown options generator #237

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
25 changes: 25 additions & 0 deletions src/lib/utils/dropdownOptionsGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// This file is part of React-Invenio-Forms
// Copyright (C) 2024 CERN.
//
// React-Invenio-Forms is free software; you can redistribute it and/or modify it
// under the terms of the MIT License; see LICENSE file for more details.

import React from "react";

export function dropdownOptionsGenerator(dropdownOptions) {
return dropdownOptions.map((options) => {
return {
key: options.key,
text: options.text,
value: options.key,
content: (
<>
<div>{options.text}</div>
<div>
<small className="text-muted">{options.description}</small>
</div>
</>
),
};
});
}
1 change: 1 addition & 0 deletions src/lib/utils/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { humanReadableBytes } from "./humanReadableBytes";
export { dropdownOptionsGenerator } from "./dropdownOptionsGenerator";
Loading