Comments (4)
The contentContainer
's purpose is to help center the content
for the Slice. Unfortunately, it doesn't help calculate its CSS layout space. If you want specific text responsiveness, you will have to set your own in the slice's content manually e.g.
const theme = {
slice: {
content: css`
width: calc(50% - 80px); /* estimated width, (probably better to set it individually for your child component) */
/* wrap or clamp text styles... */
`,
}
};
from react-pie-menu.
This is kind of tricky because the horizontal space available is different for every slice. As the number of slices increases, the horizontal space available for the top and bottom slices becomes almost unusable.
In my case the text on the Pie slices is data from the database, so I can't hand optimize each slice, I need to calculate the values somehow.
For icons and short static phrases, I think your current solution looks great. For my application I think that ideally I should have two groups of slices, one on the left side and one on the right side with no slices that are near vertical. I think I can do this by adding dummy slices that are made invisible via CSS, but they would still be clickable.
Can you think of any features that could be added to make my use case work a little better?
Even a simple change like being able to control the overflow
on the li
element would help. Right now it is set to hidden
but visible
would work better for me.
from react-pie-menu.
- The overflow css can already be controlled by overriding the style in the theme object:
const theme = {
pieMenu: {
container: css`
overflow: visible;
`,
item: css`
overflow: visible;
`,
},
},
};
Turning off the clipping also affects the slice's background and highlight. However, maybe you don't need the background or highlighting per slice. e.g.:
const theme = {
pieMenu: {
container: css`
overflow: visible;
`,
item: css`
overflow: visible;
`,
},
},
slice: {
container: css`
background: none;
&:hover {
background: none;
}
`;
}
};
-
Calculating the vertical and horizontal dimensions of the content will be difficult to get perfect, but possible. In theory
radius
size should be determined, based on some average criteria e.g.calculatedWidth
formax-height
orcalculatedHeight
formax-width
of each Slice'scontent
. This will need to be calculated on post-render. -
Another approach could be to choose to stick labels over the slice's content. This would avoid having labels as part of the child, but you would be managing positions/styles on your own e.g.:
import React from 'react';
import PieMenu, { Slice } from 'react-pie-menu';
import styled from 'styled-component';
import { layout , position } from 'styled-system';
const WidgetContainer = styled.div`
position: relative;
${layout}
`;
const Label = styled.div`
position: absolute;
${position}
`;
export default ({ data, radius }) => {
const refs = data.map(() => React.createRef(null));
const [mounted, setMount] = React.useState(null);
React.useEffect(() => setMount(true), []);
return (
<WidgetContainer width={radius} height={radius}>
<PieMenu radius={radius}>
{data.map((item, i) => (
<Slice><i ref={refs[i]} className={item.icon} /></Slice>
)}
</PieMenu>
{mounted && data.map((item, i) => {
const { left, right } = calculate(refs[i]); /* e.g. calculate where to position around the icon */
return <Label left={left} top={top}>{item.label}</Label>
}}
</WidgetContainer >
);
};
from react-pie-menu.
I didn't realize that I can have item
in my theme. This will already improve the situation.
Thank you for all of your suggestions.
from react-pie-menu.
Related Issues (20)
- Awesome component! how to set the BorderStyle of each Slice ? HOT 2
- React Native support HOT 3
- Installation fails with "Cannot read property 'length' of undefined" HOT 6
- Issues getting started HOT 2
- How to apply styling HOT 3
- Radius varies with the number of slices HOT 14
- Add example gif to README
- How to add delay on click? HOT 2
- onMouseOver causes child elements to also trigger the callback HOT 1
- onMouseOver is triggered while outside of the viewable item element HOT 1
- Slice regions don't scroll with page
- Slice collision regions don't scroll with page properly HOT 8
- Pie Menu not opening on Full calander for mobile HOT 7
- bump styled-components-theme-connector HOT 3
- Dependency Dashboard
- NPM repository has old version of package.json HOT 9
- Fails first client-side render after rendering server-side (via Next.js) HOT 3
- onSelect of Slice component registers the event twice HOT 7
- Simplified rewrite of react-pie-menu
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-pie-menu.