-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
renderIcon
to customize button icons and drag icon (#962)
* Add renderIcon * fluent * bootstrap * antd * . * mui * iconProps * chlog * lint fix * type fix
- Loading branch information
Showing
38 changed files
with
470 additions
and
184 deletions.
There are no files selected for viewing
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
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
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
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
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,24 @@ | ||
import React from "react"; | ||
import { PlusOutlined, PlusCircleOutlined, DeleteFilled, HolderOutlined } from "@ant-design/icons"; | ||
import { Utils } from "@react-awesome-query-builder/ui"; | ||
const { DragIcon } = Utils; | ||
|
||
const typeToIcon = { | ||
"addRule": <PlusOutlined />, | ||
"addGroup": <PlusCircleOutlined />, | ||
"delRule": <DeleteFilled />, | ||
"delGroup": <DeleteFilled />, | ||
"delRuleGroup": <DeleteFilled />, | ||
"addRuleGroup": <PlusOutlined />, | ||
"addRuleGroupExt": <PlusOutlined />, | ||
"drag": <HolderOutlined />, | ||
}; | ||
|
||
export default ({type}) => { | ||
let icon = typeToIcon[type]; | ||
if (!icon && type === "drag") { | ||
icon = <DragIcon />; | ||
} | ||
|
||
return icon || null; | ||
}; |
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
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
55 changes: 29 additions & 26 deletions
55
packages/bootstrap/modules/widgets/core/BootstrapButton.jsx
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 |
---|---|---|
@@ -1,34 +1,37 @@ | ||
import React from "react"; | ||
import { Button } from "reactstrap"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faPlus, faTrashAlt } from "@fortawesome/free-solid-svg-icons"; | ||
|
||
export default ({ type, label, onClick, config }) => { | ||
const hideLabelsFor = { | ||
"addRuleGroup": true | ||
}; | ||
const typeToIcon = { | ||
delGroup: faTrashAlt, | ||
delRuleGroup: faTrashAlt, | ||
delRule: faTrashAlt, | ||
addRuleGroup: faPlus, | ||
addRuleGroupExt: faPlus, | ||
addRule: faPlus, | ||
addGroup: faPlus, | ||
}; | ||
const typeToColor = { | ||
addRule: "primary", | ||
addGroup: "primary", | ||
delGroup: "danger", | ||
delRuleGroup: "danger", | ||
delRule: "danger", | ||
const hideLabelsFor = { | ||
"addRuleGroup": true, | ||
"delRuleGroup": true, | ||
"delRule": true, | ||
}; | ||
|
||
const typeToColor = { | ||
addRule: "primary", | ||
addGroup: "primary", | ||
delGroup: "danger", | ||
delRuleGroup: "danger", | ||
delRule: "danger", | ||
}; | ||
|
||
export default (props) => { | ||
const { type, label, onClick, renderIcon, readonly } = props; | ||
const iconProps = { | ||
type, | ||
readonly, | ||
}; | ||
const Icon = renderIcon?.(iconProps) || null; | ||
|
||
let isOnlyIcon = hideLabelsFor[type] || !label; | ||
|
||
return ( | ||
<Button size="sm" color={typeToColor[type]} onClick={onClick}> | ||
<FontAwesomeIcon icon={typeToIcon[type]} /> {!isOnlyIcon && label} | ||
</Button> | ||
); | ||
if (!onClick) { | ||
return Icon; | ||
} else { | ||
return ( | ||
<Button size="sm" color={typeToColor[type]} onClick={onClick}> | ||
{Icon}{!isOnlyIcon && label} | ||
</Button> | ||
); | ||
} | ||
}; |
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,28 @@ | ||
import React from "react"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faPlus, faTrashAlt, faUpDown } from "@fortawesome/free-solid-svg-icons"; | ||
import { Utils } from "@react-awesome-query-builder/ui"; | ||
const { DragIcon } = Utils; | ||
|
||
const typeToIcon = { | ||
delGroup: faTrashAlt, | ||
delRuleGroup: faTrashAlt, | ||
delRule: faTrashAlt, | ||
addRuleGroup: faPlus, | ||
addRuleGroupExt: faPlus, | ||
addRule: faPlus, | ||
addGroup: faPlus, | ||
drag: faUpDown, | ||
}; | ||
|
||
export default ({ type }) => { | ||
let icon = typeToIcon[type] | ||
&& <FontAwesomeIcon | ||
icon={typeToIcon[type]} | ||
/>; | ||
if (!icon && type === "drag") { | ||
icon = <DragIcon />; | ||
} | ||
|
||
return icon; | ||
}; |
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
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
.svg-inline--fa { | ||
pointer-events: none; | ||
} | ||
.btn > .svg-inline--fa { | ||
margin-right: 4px; | ||
} | ||
.rule--drag-handler .svg-inline--fa { | ||
margin-left: 6px; | ||
} |
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
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
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
Oops, something went wrong.
25ae3a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-awesome-query-builder-examples – ./packages/examples
react-awesome-query-builder-examples-ukrbublik.vercel.app
react-awesome-query-builder-examples-git-master-ukrbublik.vercel.app
react-awesome-query-builder-examples.vercel.app
25ae3a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-awesome-query-builder-sandbox-next – ./packages/sandbox_next
react-awesome-query-builder-sandbox-next.vercel.app
react-awesome-query-builder-sandbox-next-git-master-ukrbublik.vercel.app
react-awesome-query-builder-sandbox-next-ukrbublik.vercel.app
25ae3a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-awesome-query-builder-sandbox – ./packages/sandbox
react-awesome-query-builder-sandbox-ukrbublik.vercel.app
react-awesome-query-builder-sandbox.vercel.app
react-awesome-query-builder-sandbox-git-master-ukrbublik.vercel.app