Skip to content

Instantly share code, notes, and snippets.

View OmarZeidan's full-sized avatar
:octocat:
Building up

Omar Zeidan OmarZeidan

:octocat:
Building up
View GitHub Profile
@OmarZeidan
OmarZeidan / index.html
Created June 16, 2020 09:03
8LOGO Loading
<style>
.logo-holder {
display: flex;
justify-content: center;
align-items: center;
background-color: #000;
width: 80px;
height: 80px;
border-radius: 9999px;
}
@OmarZeidan
OmarZeidan / index.js
Created February 27, 2020 00:00
Highlight search text in ReactJS
// @Source: https://stackoverflow.com/questions/30474506/replace-part-of-string-with-tag-in-jsx
// Also see: https://github.com/facebook/react/issues/3386 For some alternatives and libraries
function getHighlightedText(text: string, higlight: string) {
// Split on higlight term and include term into parts, ignore case
const parts = text.split(new RegExp(`(${higlight})`, 'gi'));
return (
<span>
{parts.map((part, i) => (
<span
@OmarZeidan
OmarZeidan / App.tsx
Last active February 8, 2020 21:16
Spreading props for input element in React with typescript and emotion styled component
import React from 'react';
import InputC from './Input';
<InputC
type="text"
placeholder="Search by name or email address."
/>
// One problem I find here that you can give the input a property that it shouldn't be part of the input
// e.g `src` 🤷🏻
@OmarZeidan
OmarZeidan / regexs.js
Last active February 5, 2020 10:39
Helpers Functions; Regeex;
// Arabic and English letters mixed!
const regexTst = /^[\A-Za-z\.\,\u0600-\u065F\u066A-\u06EF\u06FA-\u06FF\'\s\.\,]+$/;
// Only English Letters
const regexTst = /^[a-zA-Z\s]*$/;
// Numbers Only
const regexTst = /^[0-9_\-\)\(\+]+$/i;
// Alpha Only
@OmarZeidan
OmarZeidan / gitcommits
Last active January 24, 2020 13:14
Semantic commit messages
feat: 🎉(new feature for the user, not a new feature for build script)
fix: 🛠 (bug fix for the user, not a fix to a build script)
docs: 📚 (changes to the documentation)
style: 💅🏻(formatting, missing semi colons, etc; no production code change)
refactor: 😎 (refactoring production code, eg. renaming a variable)
test: 💩 (adding missing tests, refactoring tests; no production code change)
chore: 🩺(updating grunt tasks etc; no production code change)
Example:
@OmarZeidan
OmarZeidan / utils.ts
Last active January 19, 2020 20:57
Polyfill NodeList.prototype.forEach
function polyfillNodeList() {
NodeList.prototype.forEach = function(callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
@OmarZeidan
OmarZeidan / webpack.config.js
Created June 4, 2019 00:58
Fixing the loading storysource for StoryBook issue
// .storybook/webpack.config.js
const path = require('path');
const storysource = require.resolve('@storybook/addon-storysource/loader')
module.exports = function({ config }) {
config.module.rules.push({
test: /\.jsx?$/,
loaders: [storysource],
include: path.resolve(__dirname, '../'), // this fixed it, I think.
enforce: 'pre',