File tree 11 files changed +364
-134
lines changed
graphiql-toolkit/src/storage
11 files changed +364
-134
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " graphiql " : minor
3
+ ---
4
+
5
+ add ` className ` prop. Additional class names which will be appended to the GraphiQL container element
Original file line number Diff line number Diff line change
1
+ ---
2
+ " @graphiql/toolkit " : patch
3
+ ---
4
+
5
+ prefer ` localStorage ` over ` window.localStorage `
Original file line number Diff line number Diff line change @@ -133,7 +133,14 @@ module.exports = {
133
133
'no-octal-escape' : 'error' ,
134
134
'no-param-reassign' : 'error' ,
135
135
'no-proto' : 'error' ,
136
- 'no-restricted-properties' : 'off' ,
136
+ 'no-restricted-properties' : [
137
+ 'error' ,
138
+ {
139
+ object : 'window' ,
140
+ property : 'localStorage' ,
141
+ message : 'Use `localStorage` instead' ,
142
+ } ,
143
+ ] ,
137
144
'no-return-assign' : 'error' ,
138
145
'no-return-await' : 'error' ,
139
146
'no-script-url' : 'error' ,
Original file line number Diff line number Diff line change 29
29
"pre-commit" : " lint-staged"
30
30
}
31
31
},
32
- "engines" : {
33
- "npm" : " please_use_yarn_instead"
34
- },
32
+ "packageManager" :
" [email protected] " ,
35
33
"scripts" : {
36
34
"build" : " yarn build-clean && yarn tsc && yarn build:nontsc" ,
37
35
"build-bundles" : " yarn prebuild-bundles && yarn wsrun:noexamples --stages build-bundles" ,
Original file line number Diff line number Diff line change 59
59
"codemirror" : " ^5.65.3" ,
60
60
"codemirror-graphql" : " ^2.0.12" ,
61
61
"copy-to-clipboard" : " ^3.2.0" ,
62
- "framer-motion" : " ^6.5.1 " ,
62
+ "framer-motion" : " ^11.0.0 " ,
63
63
"graphql-language-service" : " ^5.2.1" ,
64
64
"markdown-it" : " ^14.1.0" ,
65
65
"set-value" : " ^4.1.0"
Original file line number Diff line number Diff line change 4
4
gap : var (--px-8 );
5
5
padding : var (--px-8 ) 0 ;
6
6
margin : 0 var (--px-8 )
7
- /* when using padding while scrolling tab items will overflow to padding area */ ;
7
+ /* when using padding while scrolling, tab items will overflow to padding area */ ;
8
8
overflow-x : auto;
9
9
list-style : none;
10
10
}
17
17
.graphiql-tab {
18
18
background : hsla (var (--color-neutral ), var (--alpha-background-light ));
19
19
20
+ /* disable shrinking while changing the operation name */
21
+ & : not (: focus-within ) {
22
+ transform : none !important ;
23
+ }
24
+
20
25
.graphiql-tab-wrapper {
21
26
position : relative;
22
27
display : flex;
Original file line number Diff line number Diff line change @@ -64,13 +64,13 @@ export class StorageAPI {
64
64
this . storage = null ;
65
65
} else {
66
66
this . storage = {
67
- getItem : window . localStorage . getItem . bind ( window . localStorage ) ,
68
- setItem : window . localStorage . setItem . bind ( window . localStorage ) ,
69
- removeItem : window . localStorage . removeItem . bind ( window . localStorage ) ,
67
+ getItem : localStorage . getItem . bind ( localStorage ) ,
68
+ setItem : localStorage . setItem . bind ( localStorage ) ,
69
+ removeItem : localStorage . removeItem . bind ( localStorage ) ,
70
70
71
71
get length ( ) {
72
72
let keys = 0 ;
73
- for ( const key in window . localStorage ) {
73
+ for ( const key in localStorage ) {
74
74
if ( key . indexOf ( `${ STORAGE_NAMESPACE } :` ) === 0 ) {
75
75
keys += 1 ;
76
76
}
@@ -80,9 +80,9 @@ export class StorageAPI {
80
80
81
81
clear ( ) {
82
82
// We only want to clear the namespaced items
83
- for ( const key in window . localStorage ) {
83
+ for ( const key in localStorage ) {
84
84
if ( key . indexOf ( `${ STORAGE_NAMESPACE } :` ) === 0 ) {
85
- window . localStorage . removeItem ( key ) ;
85
+ localStorage . removeItem ( key ) ;
86
86
}
87
87
}
88
88
} ,
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export function createLocalStorage({
25
25
removeItem : key => localStorage . removeItem ( getStorageKey ( key ) ) ,
26
26
get length ( ) {
27
27
let keys = 0 ;
28
- for ( const key in window . localStorage ) {
28
+ for ( const key in localStorage ) {
29
29
if ( key . indexOf ( storageKeyPrefix ) === 0 ) {
30
30
keys += 1 ;
31
31
}
@@ -35,9 +35,9 @@ export function createLocalStorage({
35
35
36
36
clear ( ) {
37
37
// We only want to clear the namespaced items
38
- for ( const key in window . localStorage ) {
38
+ for ( const key in localStorage ) {
39
39
if ( key . indexOf ( storageKeyPrefix ) === 0 ) {
40
- window . localStorage . removeItem ( key ) ;
40
+ localStorage . removeItem ( key ) ;
41
41
}
42
42
}
43
43
} ,
Original file line number Diff line number Diff line change @@ -225,6 +225,10 @@ export type GraphiQLInterfaceProps = WriteableEditorProps &
225
225
* rendered with a specific theme
226
226
*/
227
227
forcedTheme ?: ( typeof THEMES ) [ number ] ;
228
+ /**
229
+ * Additional class names which will be appended to the container element.
230
+ */
231
+ className ?: string ;
228
232
} ;
229
233
230
234
const THEMES = [ 'light' , 'dark' , 'system' ] as const ;
@@ -454,9 +458,14 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
454
458
455
459
const hasMultipleTabs = editorContext . tabs . length > 1 ;
456
460
461
+ const className = props . className ? ` ${ props . className } ` : '' ;
462
+
457
463
return (
458
464
< Tooltip . Provider >
459
- < div data-testid = "graphiql-container" className = "graphiql-container" >
465
+ < div
466
+ data-testid = "graphiql-container"
467
+ className = { `graphiql-container${ className } ` }
468
+ >
460
469
< div className = "graphiql-sidebar" >
461
470
< div className = "graphiql-sidebar-section" >
462
471
{ pluginContext ?. plugins . map ( ( plugin , index ) => {
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ const simpleIntrospection = {
29
29
} ;
30
30
31
31
beforeEach ( ( ) => {
32
- window . localStorage . clear ( ) ;
32
+ localStorage . clear ( ) ;
33
33
} ) ;
34
34
35
35
describe ( 'GraphiQL' , ( ) => {
You can’t perform that action at this time.
0 commit comments