Skip to content

Instantly share code, notes, and snippets.

Avatar

Manish sharma mansha99

View GitHub Profile
View page-reducer.tsx
export const fanSpeedInitial = {
level: 0,
status: 'OFF'
};
export const ROTATE_RIGHT_ACTION =
{ type: 'ROTATE_RIGHT' };
export const ROTATE_LEFT_ACTION =
{ type: 'ROTATE_LEFT' }
export function fanSpeedReducer(fanSpeed: any, action: any) {
if (action.type == 'ROTATE_RIGHT') {
View page.tsx
"use client";
import { useReducer } from "react";
import { fanSpeedInitial, fanSpeedReducer } from "./page-reducer";
export default function Home() {
const [fanSpeedCurrent, fanSpeedHandler] = useReducer(fanSpeedReducer, fanSpeedInitial);
return (
<main style={{ padding: 20 }}>
<div>
@mansha99
mansha99 / resources\views\livewire\calculator.blade.php
Created May 13, 2023 18:28
View for Livewire Calculator Component
View resources\views\livewire\calculator.blade.php
<div style="background: #aaffcc;padding:20;width:240px">
<h5>Calculator Component</h5>
<form wire:submit.prevent="multiply">
First<br/>
<input type="text" wire:model="n1" />
<br/>
@error('n1')
{{ $message }}
@enderror
<br/>Second<br/>
@mansha99
mansha99 / resources\views\livewire\receiver.blade.php
Created May 13, 2023 18:13
View for Livewire Receiver Component
View resources\views\livewire\receiver.blade.php
<div style="background: #ffaacc;padding:20;width:240px">
<h5>Receiver</h5>
{{$message}} &nbsp;&nbsp;{{$timeStamp}}
</div>
@mansha99
mansha99 / App\Http\Livewire\Receiver.php
Created May 13, 2023 18:12
Livewire components receiving Event
View App\Http\Livewire\Receiver.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Receiver extends Component
{
public $message="Received no event so far";
public $timeStamp='';
@mansha99
mansha99 / resources\views\livewire\sender.blade.php
Created May 13, 2023 18:11
View for Livewire Sender Component
View resources\views\livewire\sender.blade.php
<div style="background: #aaccff;padding:20;width:240px">
<h5>Sender</h5>
<button wire:click="fireTimestampEvent()">Gnerate Event </button>
</div>
@mansha99
mansha99 / App\Http\Livewire\Sender.php
Created May 13, 2023 18:05
A Laravel Livewire component acting as publisher (Generator) of event
View App\Http\Livewire\Sender.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Sender extends Component
{
public function fireTimestampEvent()
{
@mansha99
mansha99 / App\Http\Livewire\Calculator.php
Created May 13, 2023 18:02
A Laravel Livewire component displaying Livewire validation in action
View App\Http\Livewire\Calculator.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Calculator extends Component
{
public $n1;
public $n2;
@mansha99
mansha99 / welcome.blade.php
Last active May 1, 2023 19:00
resources/views/welcome.blade.php
View welcome.blade.php
<html>
<head>
@livewireStyles
@livewireScripts
</head>
<body>
<livewire:inventors />
</body>
@mansha99
mansha99 / inventors.blade.php
Created May 1, 2023 15:04
resources/views/livewire/inventors.blade.php
View inventors.blade.php
<div>
<select wire:model="invention">
@foreach ($list as $k => $v)
<option value="{{ $k }}">{{ $k }}</option>
@endforeach
</select> invented by
{{ $inventor }}
</div>