You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2021/03/06 04:48:38 UTC

[superset] branch master updated: test: Adds storybook to SearchInput component (#13410)

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new c1e9287  test: Adds storybook to SearchInput component (#13410)
c1e9287 is described below

commit c1e9287cf18b1e16e859cb8f02d2554fdf0df59b
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Sat Mar 6 01:48:13 2021 -0300

    test: Adds storybook to SearchInput component (#13410)
    
    * test: Adds storybook to SearchInput component
    
    * Fixes placeholder text
    
    Co-authored-by: Evan Rusackas <ev...@preset.io>
    
    Co-authored-by: Evan Rusackas <ev...@preset.io>
---
 .../components/SearchInput/SearchInput.stories.tsx | 62 ++++++++++++++++++++++
 .../components/SearchInput/SearchInput.test.jsx}   |  0
 .../{SearchInput.tsx => SearchInput/index.tsx}     |  2 +-
 3 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/components/SearchInput/SearchInput.stories.tsx b/superset-frontend/src/components/SearchInput/SearchInput.stories.tsx
new file mode 100644
index 0000000..18292fb
--- /dev/null
+++ b/superset-frontend/src/components/SearchInput/SearchInput.stories.tsx
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useState } from 'react';
+import SearchInput, { SearchInputProps } from '.';
+
+export default {
+  title: 'SearchInput',
+  component: SearchInput,
+};
+
+export const InteractiveSearchInput = ({
+  value,
+  ...rest
+}: SearchInputProps) => {
+  const [currentValue, setCurrentValue] = useState(value);
+  return (
+    <div style={{ width: 230 }}>
+      <SearchInput
+        {...rest}
+        value={currentValue}
+        onChange={e => setCurrentValue(e.target.value)}
+        onClear={() => setCurrentValue('')}
+      />
+    </div>
+  );
+};
+
+InteractiveSearchInput.args = {
+  value: 'Test',
+  placeholder: 'Enter some text',
+  name: 'search-input',
+};
+
+InteractiveSearchInput.argTypes = {
+  onSubmit: { action: 'onSubmit' },
+  onClear: { action: 'onClear' },
+  onChange: { action: 'onChange' },
+};
+
+InteractiveSearchInput.story = {
+  parameters: {
+    knobs: {
+      disable: true,
+    },
+  },
+};
diff --git a/superset-frontend/spec/javascripts/components/SearchInput_spec.jsx b/superset-frontend/src/components/SearchInput/SearchInput.test.jsx
similarity index 100%
rename from superset-frontend/spec/javascripts/components/SearchInput_spec.jsx
rename to superset-frontend/src/components/SearchInput/SearchInput.test.jsx
diff --git a/superset-frontend/src/components/SearchInput.tsx b/superset-frontend/src/components/SearchInput/index.tsx
similarity index 98%
rename from superset-frontend/src/components/SearchInput.tsx
rename to superset-frontend/src/components/SearchInput/index.tsx
index 959a2c8..ba7eb2d 100644
--- a/superset-frontend/src/components/SearchInput.tsx
+++ b/superset-frontend/src/components/SearchInput/index.tsx
@@ -20,7 +20,7 @@ import { styled } from '@superset-ui/core';
 import React from 'react';
 import Icon from 'src/components/Icon';
 
-interface SearchInputProps {
+export interface SearchInputProps {
   onSubmit: () => void;
   onClear: () => void;
   value: string;