avatarGenius Turner

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2236

Abstract

was an issue remaining. The document used dark theme and the content in the external page used white background.</p><p id="0afe"><b>Hack 2: </b>Use dark-reader to automatically generate css for your external page</p><p id="f222">You can use <a href="https://darkreader.org/">dark-reader</a> to automatically apply dark style to your page. There are two options. First is to use dark-reader in your project via npm and apply dark theme automatically. For my case, this was a bit overkill and I choose the second option. Second option is to generate and export css file corresponding to dark theme of your external page and then adding that style-sheet to our <code>iframe</code>.</p><p id="df41">First install the <a href="https://darkreader.org/">dark-reader</a> add-on/extension to your browser. I have done it on Firefox. Then open your external page in that browser and enable the dark-mode in dark-reader add-on.</p><figure id="54a0"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*akq4Mmrutw6XTVdZMY9VBQ.png"><figcaption>dark-reader add-on in Mozilla Firefox</figcaption></figure><p id="ded5">When you enable dark-mode, the dark-reader has generated and applied appropriate styling to make your page dark-themed. It works great. You can also tweak around and set brightness, and contrast as well as use developer tools to further customize the design. Once you are happy with the design, click on the dark-reader browser-action button to open the popup menu and click on settings.</p><figure id="af34"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*B_-rTeDGalYJ-Ci6nyyapg.png"><figcaption></figcaption></figure><p id="0ea2">This will open up the settings view as displayed below.</p><figure id="bac9"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*dqdeQaWkTj38obrpRLEoVg.png"><figcaption></figcaption></figure><p id="1b63">Click on Manage settings and then on <b>Export Dynamic Theme</b>.</p><figure id="504a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*eoK7sNZcYxZF-xWQ3NjEIg.png"><figcaption></figcaption></figure><p id="2bb4">Great job! This will download a css file that you can add to your page to apply the styles for dark theme. Hmmm… So far so g

Options

ood. I believe most of you would do the rest of the stuff on your own, but for the sake of completeness let us add a few lines of code to the event-listeners that we created in Hack1.</p><p id="2a64">Save the css file that was downloaded by the dark-reader as <code>dark-theme.css </code>in the <code>/public</code> directory of your Next.js app. Now, add following lines inside the <code>"load"</code> event-listener.</p><div id="d14f"><pre>const link <span class="hljs-operator">=</span> doc.createElement(<span class="hljs-string">"link"</span>)<span class="hljs-comment">;</span></pre></div><div id="e451"><pre><span class="hljs-attr">link.rel</span> = <span class="hljs-string">"stylesheet"</span><span class="hljs-comment">;</span></pre></div><div id="d811"><pre><span class="hljs-attr">link.href</span> = <span class="hljs-string">"/dark-theme.css"</span><span class="hljs-comment">;</span></pre></div><div id="214b"><pre>doc.head.appendChild(link)<span class="hljs-comment">;</span></pre></div><p id="caa5">Next time when you do this, you will be able to add existing HTML files to your project with custom themes in much lesser time than the time you spent reading this document.</p><p id="3a9a">Wish you all the best and happy coding!</p><p id="ad6f">Interested in building career in web development? Checkout E-degree in JS Frameworks</p><div id="2976" class="link-block"> <a href="https://www.eduonix.com/javascript-frameworks-mini-edegree/UHJvZHVjdC00NDExNjgw"> <div> <div> <h2>JavaScript Mini E-Degree: Master JS Frameworks To The Core!</h2> <div><h3>A perfect mini-e-degree suitable for everyone who wants to master JavaScript effectively without wasting any time…</h3></div> <div><p>www.eduonix.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*OBLf0FHe3Jrk8Lbg)"></div> </div> </div> </a> </div><p id="79c1">Or my course on <a href="https://www.udemy.com/course/react-and-next-js-with-typescript/?referralCode=7202184A1E57C3DCA8B2">React + Next.js with TypeScript</a>.</p></article></body>

Why Gratitude is the Mother of Happiness

How we look at life shapes how we feel in life…

Life’s three most rewarding forms of being = being grateful, being patient and being yourself. (Pic: Hartwig HKD on Flickr)

I. A Famous Cautionary Tale

Yesterday a friend sent me an old Michael Jackson interview. “Genius,” she texted, “you’ll love this…”

Indeed, because an interview allows viewers to enter another’s view, I love seeing life thru another’s eyes… if only briefly. Especially when that “another” was once considered the King of Pop(ularity).

The interviewer showered Jackson with praise.

Bad, after all, was number one at the time, as had been all of Jackson’s previous albums. But just before the interviewer could serve more compliments, Jackson cut her off.

“I’m never pleased with anything,” he confessed, just above a whisper. Jackson went on to explain how he’s a “perfectionist.”

Initially I accepted the claim as justification for Jackson’s well-documented sadness. But on second thought, I said to myself — “Wait a sec….”

…And on third thought, I recalled a famed line from Hamlet:

“There’s something in this more than natural, if philosophy can find it out.”

— Shakespeare

The more Jackson allowed me to enter his view, the more clearly the question bubbled to the surface of my consciousness.

“How come…” I mumbled to myself, “History’s most successful entertainer was also her most depressed?”

For Jackson, by the time he’d reached his forties, this thing called “life” had become a living hell. Literally.

Escapism, that’s what I like,” Jackson said. “I’m not so crazy about the reality of everything.”

Perhaps drunks and addicts don’t struggle with sobriety. Rather, they struggle with reality. And Jackson was no exception.

Because sleep is the purest form of escapism, Jackson put an anesthesiologist on the payroll. Propofol, unfortunately, taught Jackson why sleep is the cousin of death.

The King of Pop tragically died in his sleep. Wait! Perhaps I can stress this point a tad better. After all, Jackson wasn’t the only “royal” entertainer on the world’s stage fated to such a tragic exeunt:

The King of Rock, the Queen of Pop and the Prince all died at the hands of an overdose….

…Overdose of what?

Drugs, aka the world’s most popular form of escapism.

Sometimes a picture is worth more than a thousand words. (Screenshot by authors; all pics from Wikimedia Commons.)

In short, this suffering that pained the “Royal Family of Music” to the very end was by no means exclusive. No, no. Rather, these royals merely fell victim to what’s historically been called the human condition.

Buddha had a name for such universal suffering — dukkha.

II. The Root of Universal Suffering — ‘Dukkha’

“I teach one thing and one thing only — dukkha and the end of dukkha.”

— Buddha

Wisdom, said Socrates, begins with clear definitions. Today we call his famed practice of ruthlessly defining key terms the Socratic method.

If Buddha, one of history’s greatest spiritual teachers, made silencing dukkha the very heart of his message (dharma), quite naturally the question becomes: What is dukkha?

Dukkha, a word borrowed from the Pali language, means “suffering.” But once we arm ourselves with the Socratic method, it becomes clear the Buddha was groping with something far deeper.

By dukkha, the Buddha meant we’re never quite satisfied. Never.

Ever notice — the Average Man wants to be rich… the Rich Man wants to be king… the King wants to rule the world? The operative word here is “wants.”

Bingo!

Perhaps the King of Popularity taught us why dukkha stems from a particular mindset. In Jackson’s case, all the world’s fame + fortune couldn’t save him from having a mind that was set on this grim view:

“I’m never pleased with anything…”

— Michael Jackson

III. What’s ‘Happiness,’ Anyway…?

Pic; DaPuglet on Flickr

Ride a New York City subway and you’re bound to notice frowning is the rule. Smiling — the exception.

“What is needed to eradicate the depression epidemic?” several scholars ask in a joint science paper. Clearly the question, though loaded, reveals the widespread nature of depression.

Dear reader, do me a favor. Take a few seconds to pause for reflection…

…And then, ask yourself: How many genuinely “happy” people do I know, myself included?

Wait! If Aristotle had it right that everything we do is for happiness, the question naturally becomes: What exactly is happiness?

Also, why do we seemingly struggle to maintain this ideal state of mind, which Aristotle called the very “meaning and purpose of life”?

Armed with the Socratic method, the following insight becomes apparent:

An attitude of gratitude = the mother of happiness.

Let me explain…

…Happiness, you see, is trendy. She’s cool. She’s always in vogue.

Take for example the lottery winner. Thirty seconds ago he resembled a pallbearer at some funeral. But now, after being told of the winning numbers, he jumps for joy.

Onlookers say “Wow, he’s happy.” But in reality, what they meant to say is this:

That same slump-shouldered man who, just seconds before, handed over his last few bucks to buy a few scratch-off tickets, which indicates financial LACK, upon learning he’d just won $50,000 — now finds himself filled with gratitude.

The burst of energy that floods his once dejected body reflects feeling appreciative.

Notice what’s being suggested here…

IV. The World’s Silently ‘Contagious’ Disease

Not even being celebrated as the world’s most “beautiful” woman could spare Marilyn from her lifelong bout with the world’s silently contagious disease. (Pic: deviantart.com)

In a world where 828,000,000 people suffer from hunger, how many fortunate diners express gratitude for breakfast?

Or for lunch?

Or for dinner?

How many of us, while gorging on the recent Thanksgiving feast, actually felt grateful for such good fortune?

How many of us are thankful we’re not blind or deaf? After all, Helen Keller didn’t ask Nature to rob her of not only sight but also of hearing while only 19 months old.

How many of my fellow Americans truly appreciate living in the free world? Indeed, by no means does living in a free land indicate the residents feel free.

If any citizen dares to leave North Korea, on the other hand, such “treachery against the nation” is considered a crime punishable by death.

In short, according to findings published by Harvard Medical School, giving thanks makes you happier. But in a world where taking things for granted has become the rule and gratitude the exception, is not the following insight apparent?

Unhappiness has become a pandemic caused by our chronic lack of gratitude.

Indeed, our society’s chronic lack of gratitude has become contagious — daily contaminating us all.

Bingo!

Jack reaches a milestone of 1,000 followers on Instagram. He’s stoked. Congrats, Jack! Ahh, but just before patting himself on the back, Jill reminds him she has 10,000 followers.

Dissatisfaction abruptly convinces Jack to trade his hope for despair.

Jill has unknowingly nudged Jack to focus on what he doesn’t have instead of focusing on what he has. “Have-nots” are miserable. And such is the nature of this contagious disease that’s spread from person to person — by our chronic lack of gratitude.

Comparisons are the thief of gratitude! And because lasting happiness is impossible without gratitude, this explains why so many suffer from the world’s silently contagious disease.

Perhaps this explains why Prince, when sensing the apple never falls far from the tree, mournfully compared his lover’s ailment to his very own mother’s condition:

“Maybe you’re just like my mother, She’s never satisfied…”

—Prince, When Doves Cry

Just as monkey see… monkey do, this means — human don’t see, human don’t do. And with so few shining examples of how to live a life of gratitude, unhappiness has become the pandemic caused by our chronic ingratitude.

V. Gratitude — the Mother of Happiness

Pic: Flickr.com

Yesterday, my auntie wished me a Happy Thanksgiving. After exchanging pleasantries, I asked how she was feeling.

“Ohh, nephew…” she groaned. “Been feeling depressed of late.”

Whenever someone mentions they’ve been stressing out, I usually counter by stressing their good health. (Energy flows where attention goes, after all.) Not to mention, a healthy woman wants everything — the sick woman only wants one.

“Oh, I’m as healthy as ever, nephew,” she said. “Even did my 30 minutes on the treadmill earlier.”

I clapped. Seconds later I asked about her shelter. In our nation alone, over 500,000 of our fellow Americans are homeless, after all.

“I love our new home, nephew!” She smiled from ear to ear. “Your uncle can’t wait to decorate for Christmas.”

After about a minute or so of helping my auntie check off life’s most important necessities, she finally had an aha! moment.

As I explained to her — because happiness is a state of mind, not a state of body or a state of possessions, whoever wants to live permanently in this blessed state must first, above all, relocate to the “City of Gratitude.”

Gratitude is the capital of the state of Happiness.

In short,

The happiest people rarely have the most, but are usually the most grateful for what they have.

Depression and most stress-related diseases stem from our inability to appreciate life’s best gifts. And remember, the best things in life are not only free but they’re not even “things.”

→ Has the eye ever seen love?

→ Has the ear ever sniffed happiness?

→ Has the tongue ever tasted peace?

In short, whenever we obsess over what we had — or what we wish to have — it always comes at the price of devaluing what we already have.

Perhaps this explains why Socrates warned his disciples if they’re not contented with what they have, there’s no way they’ll be contented with what they wish to have.

For this reason, I’m convinced of this:

Gratitude is the mother of happiness.

Perhaps in Prince’s reference to his perpetually ungrateful mother, he merely used a maternal figure to personify the root of unhappiness.

As for my own part, I’ll say this much…

VI. What Having an ‘Attitude of Gratitude’ Looks Like

This year my grandmother, who helped raise both me and my teenage mother, three days after my birthday — “went home to see the Lord.”

Fortunately having an attitude of gratitude allowed me to glimpse a rainbow in such a dark cloud.

“Thank you, good Lord, for blessing me with both the means and flexibility to have spent the last few months with the apple of my eye,” I said in a silent prayer seconds before delivering her eulogy.

In her final days, my mother’s mother taught me why gratitude is the mother of happiness.

Sensing she had such few grains left in the hourglass, we savored each moment. Prayed over every meal. Took trips together down memory lane.

Each night before retiring, she told me to “put Tyler [Perry] on.” Indeed, she never missed the chance to remind us Perry also hails from a 3rd Ward and shares her birthday. The mere sound of Madea’s voice will forever fill my heart with gratitude.

In my grandma’s absence, I now start each morning feeling grateful to open these two gifts — they’re called my eyes.

As for saying thanks for another day, given that roughly 150,000 people twirl into the Reaper’s grim arms each day, I make sure to — count my blessings before I count my money.

In short, in her final days, my mother’s mother taught me why gratitude is the mother of happiness.

VII. The Takeaway

Jesus of Nazareth teaches the rich man to refrain from wasting money on trying to buy happiness. After all, “the Kingdom of Heaven is within you.” (Pic: Frederick Noronha on Flickr.com)

Just as three parts make up the atom, the following triad makes up happiness:

Gratitude → Satisfaction → Optimsim

Bingo!

It’s impossible to be sad and grateful at the same time. Impossible! Heck, I’ll go so far as to say — your chances of seeing Santa ride a unicorn are better than seeing a happy ungrateful person.

Why?

Quite simple, Gratitude births satisfaction… Satisfaction breeds optimism… Optimism produces gratitude. In that order.

Dear reader, wed your heart to the above triad — the “GSO.”

(*Note: see my Law of Three article for more insight.)

Did not the Buddha teach us that “happiness does not depend on what you have or who you are, it solely relies on what you think”?

In an age where most people privately believe fame will silence dukkha, history begs to differ. But unfortunately, the greatest lesson we learn from history is that we never learn from history…

…Sure, we read reports that Elon Musk suffers from daily bouts of depression, despite being the richest person on the planet. Yet we still naively think to ourselves: “Musk is kinda crazy. I’m sane. Yep. So once I make my fortune, I’ll finally put an end to this daily suffering.”

You don’t say!

As for fame, most of us secretly believe entering the world of celebrity offers a stairway to heaven. Uhn-uh…

…Ahem, whoever dares listen closely is bound to hear the Royal Family of Music whisper this: no amount of screams and fans will ever fan away the smoke and screams from a burning soul.

Indeed, never has a change in circumstances resulted in a change of character flaw. Never! After all, circumstances merely reveal character. If saddled with that same “never-quite-satisfied mindset” that hounded the likes of Jackson and Elvis, ahem, well, fame will only serve as another drug.

In short, most people misidentify happiness with celebration, the root of which is celebrity. Hence the lust for being a celebrity.

But again, being either celebrated by fans or celebrating with money still won’t help you feel grateful. Right?

Perhaps the above explains why when an iconic comedian and movie star was asked about being rich and famous, he confessed:

“I wish everyone could get rich and famous and everything they ever dreamed of so they can see that’s not the answer.”

— Jim Carrey

Perhaps it’s not so much we become happy as do we learn to stop being unhappy. The instant we master having an attitude of gratitude, happiness befriends us.

Unhappiness has become a pandemic that’s both caused and spread by our chronic lack of gratitude.

In short, the more I live, the more I’m convinced for my own happiness or unhappiness — I have only what I think about things to either thank or blame.

After all,

Change how you look at things = things you look at change

For this reason, gratitude is the mother of happiness.

Self Improvement
Life Lessons
Life
Psychology
Self
Recommended from ReadMedium