Skip to content

Instantly share code, notes, and snippets.

View Rajdeepc's full-sized avatar

Rajdeep Chandra Rajdeepc

View GitHub Profile

Migrating from React Spectrum to swc-react

Overview

swc-react is a collection of React wrapper components for Spectrum Web Components (SWC), providing a framework-agnostic approach with web components at the core. When migrating from React Spectrum to swc-react, follow these guidelines to ensure a smooth transition.

Key Differences

  1. Package Structure: React Spectrum uses a monolithic package (@adobe/react-spectrum), while swc-react uses individual packages per component (@swc-react/button, @swc-react/textfield, etc.)
@Rajdeepc
Rajdeepc / gist:c9f56d69cd2baa54a2a6dfa1c970ef97
Created June 27, 2025 13:34
Spectrum 1 and Spectrum 2 Token Values
| Token | Old Value | New Value |
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `--spectrum-drop-shadow-color-rgb` | `0, 0, 0` | `(missing)` |
| `--spectrum-drop-shadow-color-opacity` | `0.15` | `(missing)`
@Rajdeepc
Rajdeepc / blinkingdot.js
Created November 17, 2020 09:26
blinking dot
//html
<svg height="20" width="20" className="blinking">
<circle cx="5" cy="5" r="5" fill="red" />
Sorry, your browser does not support inline SVG.
</svg>
// css
@Rajdeepc
Rajdeepc / htmlhacks.js
Last active November 12, 2020 16:06
DIsable text selection and turn off inspect element on a webpage
// To disable text selection on your webpage try this css
body {
-webkit-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
@Rajdeepc
Rajdeepc / error_boundary.js
Created June 27, 2020 06:07
React_Error_Boundary
import React from 'react'
import PropTypes from 'prop-types'
class ErrorBoundary extends React.Component {
constructor(props) {
super(props)
this.state = { hasError: false }
}
componentDidCatch(error, info) {
@Rajdeepc
Rajdeepc / redux_action_jest.js
Created May 20, 2020 16:01
Testing Async Redux Action
//
const searchAction = (value) => dispatch => {
dispatch({
type: SEARCH_TEXT,
text: value
})
}
//Test
@Rajdeepc
Rajdeepc / axios_http_interceptor.js
Created May 20, 2020 10:09
Adding HTTP Interceptor to Axios
//example auth token
const AuthToken = 'az=saasdnqwqnx71231n1alsk123-123123sx';
// creating the interceptor
axios.interceptors.request.use(
config => {
config.headers.authorization = `Bearer ${AuthToken}`;
return config
@Rajdeepc
Rajdeepc / server.js
Created May 11, 2020 11:40
Run a GraphQL server
//defining graphql schema
const { gql, ApolloServer } = require("apollo-server") ;
const typeDefs = gql`
type Query {
greeting: String
}
`;
@Rajdeepc
Rajdeepc / dynamic_imports.js
Created May 11, 2020 09:22
dynamic imports and code splitting in React
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
class App extends Component {
state = {
modal: null
}
@Rajdeepc
Rajdeepc / showhidenav_reactrouter.js
Created May 4, 2020 16:40
show hide navbar and footer in routes with react-router-dom
//App.js
import React from "react";
import Routes from "./routes.js";
import NavbarComponent from "./components/Navbar";
import { withRouter } from "react-router-dom";
const App = ({ location }) => {
return (