Skip to content

Instantly share code, notes, and snippets.

View Bwogi's full-sized avatar

Andrew Bwogi Bwogi

View GitHub Profile

Creating an Express.js instance to pull data from a MySQL database

Table of Contents

  1. The Server Code
  2. The Explanation

Server

import express from 'express';
@Bwogi
Bwogi / tailwind-css-gradients.md
Last active November 7, 2022 15:26
tailwind css gradients explained

Tailwind css gradients explained

I will be updating this gist time and again.In this gist, i show how you how you can use gradients to improve your front end.

Repo

https://github.com/Bwogi/modals-in-action

two colour combinations

Person component

The Person component has a gradient flowing from left to the right from white color to a grey shade.

className = 'bg-gradient-to-r from-white to-gray-500 ...'

Creating Modals in Reactjs - Process

  1. Create the modal component you wish to load
  2. Let the onClick event of your button point to a function, say paymentHandler
  3. Import this model to where you want to load it
  4. Import the useState hook
  5. Set it to false
  6. Destructure it to have paid variable and setPaid function
  7. In the paymentHandler function, set the setPaid function to true
  8. Below the button with this event, output a dynamic expression there where if paid variable is true, then load the modal component or if false, null.
@Bwogi
Bwogi / check-breakpoints.md
Created January 13, 2022 23:58
Checking for different check
const theme = useTheme();
	const matches = useMediaQuery(theme.breakpoints.up('sm'));
	// console.log(matches);
						{matches ? <span style={{}}>Secure Social Media</span> : ''}

thanks to Adnan Niaz

@Bwogi
Bwogi / destructuring.md
Created December 2, 2021 00:33
Destructuring explained

destructuring explained

The syntax also works on arrays:

const a = [1, 2, 3, 4, 5]
const [first, second] = a

This statement creates 3 new variables by getting the items with index 0, 1, 4 from the array a:

@Bwogi
Bwogi / propsExplained.md
Last active December 11, 2021 23:08
This is how props work in React ;) and styles

Props & component styles Explained

example 1 (header.js)

import React from 'react';

const Header = ({ title, year, message }) => {
	return (
		<header>
			<h3 style={headerStyles}>
				{title} {year} - {message}
@Bwogi
Bwogi / useStateExplained.md
Last active December 11, 2021 12:52
State management explained in React

useState explained

Isn't this beautiful?(/components/Counter/index.js)

import { useState } from 'react';
const Counter = ({ max }) => {
	const [count, setCount] = useState(0);
	return (
		<div>
			<h1>Walmart Guests: {count}</h1>
			<h3>out of: {max}</h3>
@Bwogi
Bwogi / map_func.md
Last active July 14, 2022 20:44
How to map objects in an array in reactjs

How you actually use the map function and more

With one property

theObject.map((itsSingular) => (<element>{itsSingular.property1}</element>))

With more properties

where property1 is the key

theObject.map((itsSingular) => (
<element key={itsSingular.property1}>{itsSingular.property1}</element>
@Bwogi
Bwogi / link_to_main_article.md
Last active November 21, 2021 03:28
This is how you link an article to itself(main) by id in next.js

Linking an article to the main article by id

Take special interest in the following code

<Link href='/article/[id]' as={`/article/${article.id}`}>

This is the main article

I have called this ArticleItem.js