How do you distinguish between FontAwesome's circles? - reactjs

I am rendering an icon in my React Native app, and have to specify the checked/unchecked icon type. I am reading the list of FontAwesome icons here: https://fontawesome.com/icons?d=gallery&q=circle
There are many different circle icons called "circle". When I specify "circle" as the icon type in my app, it uses the filled circle by default, but I want to use the outline circle. Does anyone know how to do this? Specifically, I am rendering a <CheckBox> component and specifying the uncheckedType field.

I’d recommend using react-native-vector-icons which includes FontAwesome. Check out the directory of all the icon packs here.
That all have unique names, so the code would look something like this:
import Icon from 'react-native-vector-icons/FontAwesome';
const checked = <Icon name="circle" size={30} color="#900" />;
const unchecked = <Icon name=“circle-o” size={30} color={#900} />;
This will make it really easy to quickly add all kinds of icons into your app!

Related

How to create React Modal that doesn't have any overlay?

I am using React and Semantic UI for my website and I'm looking to create a modal popup to provide some action items on the page.
Currently, with Semantic's Modal, you must choose between three dimmer options (Default, inverted and blurring). In my case, I want the pop-up to appear, but I don't want ANY overlay. The page behind the model should appear as normal. Strangely, this isn't easy/obvious to implement.
On my page, I have the following example model code.
<Modal dimmer="inverted" size='mini' open={this.state.modalopen} onClose={this.onClose}>
<Modal.Header>Select a Photo</Modal.Header>
<Modal.Content image>
<Modal.Description>
<p>Some contents.</p>
</Modal.Description>
</Modal.Content>
</Modal>
The three options (default,inverted and blur) obviously don't work.
I have tried using styling to set the background color to transparent and other optoins, but nothing seems to work.
<Modal style={{backgroundColor: "transparent"}} dimmer="inverted" size='mini' open={this.state.modalopen} onClose={this.onClose}>
I know there must be an easy solution here..what is it?
Thx for your help.
Is used to be possible to set dimmer={false}, but this is deprecated (see link below) according to the documentation, and you will need to use styling in order to make it transparent, so your solution is close to what you need to do. If you inspect the rendered Modal, you'll see that you need to override the background-color of the .ui.dimmer css class. You should be able to do that in your component's stylesheet.
https://github.com/Semantic-Org/Semantic-UI-React/pull/2882

How do I set my default theme for all icons on Antd?

I am looking to set the default theme for all the Icons that I'm using through ANTD to 'filled' rather than having to pass theme='filled' to every individual icon I create. I have many instances of Icon throughout my APP and going to pass in that to every one (as well as modals) , it would be time consuming. How can I go about setting a default theme on all icons to be 'filled' without changing every instance (also effecting icons used in modals).
There is no direct way to modify at one place and it will reflect to all places. But you can always wrap Icon component of andt for your custom component like following
const CustomIcon = (props) => {
return (
<Icon theme="filled" {...props} />
)
}
Also, you can use regex to search the icon component in all your files and change/add theme to filled.
NOTE: Many icons in default theme are not present in other themes.

How to reproduce Material-UI card style

I am studying about Material-UI but I couldn't find in the Demo (example) anything similar with what they have in their website.
My problem is I want to copy this example, so I am trying to reproduce the container (not the content) using the <Card /> component, but it doesn't reproduce very well, so I want to know if there is a specific component to use.
If I understand your question correctly, you're looking for a way to emulate the collapsible demo container that reveals the code behind the demos in Material-UI's documentation (and you want to do so using Material-UI components).
That specific container is implemented in the docs site as an internal component and is composed of Material-UI components with a reliance on JSS for styling. It is also open-source, so looking at the code should help you.
Here is an excerpt from the render method:
<div className={classes.root}>
<IconButton onClick={this.handleCodeButtonClick} className={classes.codeButton}>
<CodeIcon />
</IconButton>
<Collapse in={this.state.codeOpen}>
<MarkdownElement className={classes.code} text={`\`\`\`js\n${raw}\n\`\`\``} />
</Collapse>
<div className={classes.demo} data-mui-demo={name}>
<DemoComponent />
</div>
</div>
This is a component that is used for demos in the Material-UI documentation. It is little more than a styled div with an IconButton.
The MarkdownElement contains the code that is toggled by the code button presented at the top-right of the container. It is wrapped in a Collapse component, which handles the animated transition that takes place when the visibility of that code is toggled.
The DemoComponent is where the demo is presented.
All style is handled using JSS, defined in a stylesheet object.
I'm sure you can build this into a Card by following this pattern. It should be pretty straight-forward, something like adding an action to the CardHeader that triggers a state change and toggles whatever you're looking to expand.

How to have linear gradient background on all screens in React Native

I have an app written in React Native. I would like to have a gradient background in all screens. Maybe something like:
I have found the react-native-linear-gradient package, but would I get higher performance using an image?
Also, how do I make sure it stays as a background on all pages?
Would it be something like
const Container = (props) => (
<View>
<LinearGradient colors=['blue', 'orange', 'blue'] />
{props.children}
</View>
);
and then on all my screens use
<Container>
..
</Container>
You can try to create gradient image in some graphical editors which allow you to set linear gradient from top(blue) to bottom(transparent), and place this image as background all your scenes. Its can be helpful.
But if you need to cange colors of your gradient dynamically, you need to use libraries for now.

Bootstrap DropdownButton Styling

I have the following code:
header_contents.push(<DropdownButton bsSize='xsmall' bsStyle='link' pullRight={true} id={1} title='Menu'>
{item_menu}
</DropdownButton>);
I want to have the styling in Bootstrap to be white lettering (currently blue) as I think the link option is defaulted to that. How can you change the styling for Bootstrap to pass link color, and other properties like if you want to move the link down a little on the page?
I should mention we do very little CSS styling as most of that is done within the ReactJS components.
Either override bootstrap CSS in a css file (that is what your seem to avoid I understand): it is the better way to ensure a global effect over every link in your application.
Or do no sent bsStyle='link' as DropdownButton property but instead, insert a style property with custom CSS. Yet you can insert style even if you don't remove bsStyle. You could then create your own component wrapping DropdownButton to ensure the same graphic chart in your application.
I figured it out with the help of an online chat room. Here's what I did.
I first made a style (dropDownLinkStyle) in the react component like this.
let dropDownLinkStyle = {
color: 'white'
};
Then I used it (dropDownLinkStyle) in the dropdownButton like this.
header_contents.push(<DropdownButton bsSize='large' style={dropDownLinkStyle} bsStyle='link' pullRight={true} id={1 /* avoids react warning */} title='Menu'>
{item_menu}
</DropdownButton>);
I hope this helps. This allowed me to keep my bsStyle which is link (tells Bootstrap I want a link type on my screen instead of a button) and allows me to change that link to white lettering. I could also pass more styling by just adding it to the object -- dropDownLinkStyle

Resources