Skip to content

Instantly share code, notes, and snippets.

View sh-ravan's full-sized avatar

Shravan sh-ravan

View GitHub Profile
import Input from '../components/atoms/input.vue';
export default {
title: 'Components/Atoms',
component: Input,
argTypes: {
type: {
control: 'radio',
options: ['text', 'email'],
},
<script setup>
import { ref } from 'vue';
const props = defineProps({
type: {
type: String,
default: 'text',
validator(value) {
return ['text', 'email'].includes(value);
},
@sh-ravan
sh-ravan / rotate.js
Created December 21, 2022 07:20
Asynchronously rotate base64 image (Javascript)
const rotate = async (srcBase64, degrees = 90) => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const image = new Image();
image.src = srcBase64;
await image.decode();
canvas.width = degrees % 180 === 0 ? image.width : image.height;
canvas.height = degrees % 180 === 0 ? image.height : image.width;