noob
noob
KPCKevin Powell - Community
Created by noob on 11/20/2024 in #front-end
how to style for nested item
here is html and css I use: https://jsbin.com/kahaburocu/edit?html,css,output I'm using a function to recursive render the nested item like this
const handleRenderChildRoles = (roles: Role[], level: number) => {
return roles.map((role, index) => (
<React.Fragment key={role.id}>
<tr className={classes.row}>
<td> {!level && role.id}</td>
<td
style={{
marginLeft: `${25 * level}px`,
paddingLeft: level ? `30px` : "18px",

display: "block",
}}
className={level ? classes.subRow : ""}>
{!!level && (
<div
style={{
position: "absolute",
height: !index ? "70%" : "100%",
width: "25px",
top: index ? "-50%" : "-20%",
left: "0",
borderLeft: "1px solid #000",
borderBottom: "1px solid #000",
}}></div>
)}
{role.name}
</td>
<td>
<Popover
overlayInnerStyle={{
padding: 0,
}}
content={
<PopoverContent
onClickEdit={onClickEditOption}
onClickDelete={onClickDelete}
/>
}
placement="bottom"
trigger="click">
<Gear
onClick={() => onClickGearIcon(role)}
size={22}
style={{
margin: "auto",
display: "block",
cursor: "pointer",
}}
/>
</Popover>
</td>
</tr>
{!!role.child_role.length &&
handleRenderChildRoles(role.child_role, level + 1)}
</React.Fragment>
));
};
const handleRenderChildRoles = (roles: Role[], level: number) => {
return roles.map((role, index) => (
<React.Fragment key={role.id}>
<tr className={classes.row}>
<td> {!level && role.id}</td>
<td
style={{
marginLeft: `${25 * level}px`,
paddingLeft: level ? `30px` : "18px",

display: "block",
}}
className={level ? classes.subRow : ""}>
{!!level && (
<div
style={{
position: "absolute",
height: !index ? "70%" : "100%",
width: "25px",
top: index ? "-50%" : "-20%",
left: "0",
borderLeft: "1px solid #000",
borderBottom: "1px solid #000",
}}></div>
)}
{role.name}
</td>
<td>
<Popover
overlayInnerStyle={{
padding: 0,
}}
content={
<PopoverContent
onClickEdit={onClickEditOption}
onClickDelete={onClickDelete}
/>
}
placement="bottom"
trigger="click">
<Gear
onClick={() => onClickGearIcon(role)}
size={22}
style={{
margin: "auto",
display: "block",
cursor: "pointer",
}}
/>
</Popover>
</td>
</tr>
{!!role.child_role.length &&
handleRenderChildRoles(role.child_role, level + 1)}
</React.Fragment>
));
};
7 replies
KPCKevin Powell - Community
Created by noob on 11/20/2024 in #front-end
how to style for nested item
No description
7 replies
KPCKevin Powell - Community
Created by noob on 11/20/2024 in #front-end
how to style for nested item
My layout is a table and all rows include nested rows will have an icon in the last column. How can I handle this problem?
7 replies