"Bootstrap" as every developer knows a very popular framework for the CSS and, comes with its build in components, styles and utilities.
Recently I was using bootstrap for one of my react project. but bootstrap comes with its own default styles and I was looking for some mechanism so I can use my own styles or putting into the simple way I can customize the bootstrap styles.
During this process, I figured out the solution, In this post, In a few easy steps I am going to share how you can customize bootstrap.
STEP 1:
Include bootstrap in your application
npm install --save bootstrap
STEP 2:
To customize Bootstrap, create a file called src/custom.scss(decide the place where you want to keep your custom.scss file) and alter the value of the variable you want to customize.
// Override default variables before the import
$primary: #000;
// Import Bootstrap and its default variables
@import'~bootstrap/scss/bootstrap.scss';
You can see all the available variables inside bootstrap\scss\_variables.scss and you can select the one which you want to modify.
STEP 3 :
Import the newly created .scss file instead of the default Bootstrap .css in the beginning of your src/index.js file, for example:
import'./customCss/custom.scss';
And its done. Run your react project and see the magic.
Thanks for reading; if you find it useful or something you want to add do comment.
Jest is basically a unit testing framework which is frequently used in React but
in this post I want to share how you can use jest in gatsby for unit testing. gatsby is the static site generator using this you can create websites in react.
1. Installing dependencies
First you need to install Jest and some more required packages. You need to install Babel 7 as it’s required by Jest.
npm install --save-dev jest babel-jest react-test-renderer identity-obj-proxy babel-core@^7.0.0-bridge.0 @babel/core babel-preset-gatsby
3. Useful mocks to complete your testing environment
Mocking Gatsby
Finally it’s a good idea to mock the gatsby module itself. This may not be needed at first, but will make things a lot easier if you want to test components that use Link or GraphQL.
This mocks the graphql() function, Link component, and StaticQuery component.
__mocks__/gatsby.js
constReact = require("react")
constgatsby = jest.requireActual("gatsby")
module.exports = {
...gatsby,
graphql:jest.fn(),
Link:jest.fn().mockImplementation(({ to, ...rest }) =>
React.createElement("a", {
...rest,
href:to,
})
),
StaticQuery:jest.fn(),
}
4.Writing tests
Put test inside test folder with the extension .spec.js or .test.js.
a) Snapshot test :-
Testing simple page
-- src/pages/samplePage.js
importReactfrom'react'
constSamplePage = () => (
<div>
<h1>renders correctly</h1>
</div>
)
exportdefaultSamplePage
-- test/dummyTest.test.js
importReactfrom"react"
importrendererfrom"react-test-renderer"
importBiofrom"./Bio"
describe("Bio", () => {
it("renders correctly", () => {
consttree = renderer.create(<Bio/>).toJSON()
expect(tree).toMatchSnapshot()
})
})
Testing page wrapped inside component / shallow rendering test
In this post I am going to share A beautiful speech given by Sundar Pichai for self development. I want you to read this story and watch the video. This will help you to change your perspective to think about situations and events happening in life.
At a restaurant, a cockroach suddenly flew from somewhere and sat on a lady. She started screaming out of fear. With a panic stricken face and trembling voice, she started jumping, with both her hands desperately trying to get rid of the cockroach.
Her reaction was contagious, as everyone in her group also got panicky. The lady finally managed to push the cockroach away but …it landed on another lady in the group. Now, it was the turn of the other lady in the group to continue the drama.
The waiter rushed forward to their rescue. In the relay of throwing, the cockroach next fell upon the waiter. The waiter stood firm, composed himself and observed the behavior of the cockroach on his shirt. When he was confident enough, he grabbed it with his fingers and threw it out of the restaurant.
Sipping my coffee and watching the amusement, the antenna of my mind picked up a few thoughts and started wondering, was the cockroach responsible for their histrionic behavior?
If so, then why was the waiter not disturbed? He handled it near to perfection, without any chaos. It is not the cockroach, but the inability of the ladies to handle the disturbance caused by the cockroach that disturbed the ladies.
I realized that, it is not the shouting of my father or my boss or my wife that disturbs me, but it’s my inability to handle the disturbances caused by their shouting that disturbs me. It’s not the traffic jams on the road that disturbs me, but my inability to handle the disturbance caused by the traffic jam that disturbs me.
More than the problem, it’s my reaction to the problem that creates chaos in my life.
Lessons learnt from the story: “Do not react in life. Always respond.“
The women reacted, whereas the waiter responded.
Reactions are always instinctive whereas responses are always well thought of, just and right to save a situation from going out of hands, to avoid cracks in relationship, to avoid taking decisions in anger, anxiety, stress or hurry.
In this post I am going to share Most inspirational speech given by steve jobs.
Steve Jobs was an American entrepreneur, businessman, inventor, and industrial designer. He was the co-founder, chairman, and chief executive officer (CEO) of Apple Inc.CEO and majority shareholder of Pixar, a member of The Walt Disney Company's board of directors following its acquisition of Pixar, and founder, chairman, and CEO of NeXT. Jobs and Apple co-founder Steve Wozniak are widely recognized as pioneers of the microcomputer revolution of the 1970s and 1980s.(Source : wikipedia)
Read complete speech here : http://news.stanford.edu/2005/06/14/jobs-061505/
Your whole life can never depend on one single event. Life always have more to offer than you think it would.
Life is like riding a bicycle. To keep your balance you must keep moving.
You can not stop a bird from landing on your head, but you can keep it away from building a nest.
Don't Take Anything Personally. Nothing others do is because of you. What others say and do is a projection of their own reality, their own dream. When you are immune to the opinions and actions of others, you won't be the victim of needless suffering. ~ Don Miguel Ruiz
You can spend minutes, hours, days, weeks, or even months over-analyzing a situation; trying to put the pieces together, justifying what could’ve, would’ve happened… or you can just leave the pieces on the floor and move on.
You will be thrown down again and again, will fail countless times, and you will be beaten to the point where every doubt and fear will creep up to fight you. But you have to just keep going.
Don't be afraid to shake the apple tree a bit to see what fruits remain after.
Whenever you find yourself wasting time, remember. There is someone out there who is equipping him/her at this very moment. The day you compete with him, you’ll lose.
Your problem is you have spent your whole life thinking there are rules. There aren’t. We used to be gorillas. All we had is what we could take and defend.
If you spend too much time thinking about a thing, you’ll never get it done. ~ Bruce Lee
Life can be hard. But remember, while the difficult moments may decrease happiness, they’re essential for building meaning. And that’s what matters in the long run."
You don't get frustrated because of events. You get frustrated because of your beliefs.
Act the way you’d like to be and soon you’ll be the way you’d like to act.
Anger is not a real emotion. It is fear clothed. Figure out what you are afraid of before you get angry.
God gives his hardest battles to his toughest soldiers." You are being redirected and made strong for a purpose in your life. Its not suffering, its training. Training for you to make it big.
Eat a frog everyday(do your worst task first thing in the morning). It would be actually difficult in the beginning. But as you do it, you will start feeling better and procrastinate less in life.
And in the end, it’s not the years in your life that count. It’s the life in your years.