Skip to content

Commit

Permalink
add welcome message in the console
Browse files Browse the repository at this point in the history
  • Loading branch information
suren-atoyan committed Apr 18, 2022
1 parent 27dd6d2 commit 988a917
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import welcome from '@/utils/welcome';

// Root contains the main dependencies and providers of the base app
// - React, ReactDom, RecoilRoot, HelmetProvider, ThemeProvider, MUI-core)
// App contains the main structure of the base app
Expand All @@ -10,5 +12,8 @@ Promise.all([import('@/Root'), import('@/App')]).then(([{ default: render }, { d
render(App);
});

// welcome message for users in the console
welcome();

// ts(1208)
export {};
31 changes: 31 additions & 0 deletions src/utils/welcome.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { title } from '@/config';

// this utility is used to welcome users in the console
function getRandomRGBNumber() {
return Math.floor(Math.random() * 256);
}

function getRandomColor() {
const r = getRandomRGBNumber();
const g = getRandomRGBNumber();
const b = getRandomRGBNumber();

return [`rgb(${r}, ${g}, ${b})`, `rgb(${255 - r}, ${255 - g}, ${255 - b})`];
}

function welcome() {
const [color, invertedColor] = getRandomColor();

const styles = [
'font-size: 40px',
`color: ${color}`,
`border: 1px solid ${invertedColor}`,
`background-color: ${invertedColor}`,
'border-radius: 5px',
'padding: 10px',
].join(';');

console.log(`%c=== ${title} ===`, styles);
}

export default welcome;

0 comments on commit 988a917

Please sign in to comment.