Skip to content

Commit

Permalink
utils: add dropdown options generator
Browse files Browse the repository at this point in the history
  • Loading branch information
anikachurilova committed Apr 9, 2024
1 parent cb1ba08 commit 6f6c91a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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";

0 comments on commit 6f6c91a

Please sign in to comment.