aboutsummaryrefslogtreecommitdiff
path: root/core/search-component
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-05-12 14:58:05 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-05-21 15:26:00 +0200
commit25d826bb75a78eb674a63aed19f55e92d7ff8bca (patch)
tree72c0c1a04dd4cb301ee8d7a59fce90d5baea4662 /core/search-component
parent2ee83d06c9cc534b4f226dd30f294bc0588e8b4e (diff)
downloaddokka-25d826bb75a78eb674a63aed19f55e92d7ff8bca.tar.gz
dokka-25d826bb75a78eb674a63aed19f55e92d7ff8bca.tar.bz2
dokka-25d826bb75a78eb674a63aed19f55e92d7ff8bca.zip
Migrated resources to base-plugin
Diffstat (limited to 'core/search-component')
-rw-r--r--core/search-component/.gitignore3
-rw-r--r--core/search-component/build.gradle.kts18
-rw-r--r--core/search-component/package.json80
-rw-r--r--core/search-component/postcss.config.js17
-rw-r--r--core/search-component/src/main/js/search/app-root.js47
-rw-r--r--core/search-component/src/main/js/search/app.css21
-rw-r--r--core/search-component/src/main/js/search/app.js41
-rw-r--r--core/search-component/src/main/js/search/search.js52
-rw-r--r--core/search-component/stylelint.config.js4
-rw-r--r--core/search-component/webpack.config.js62
10 files changed, 0 insertions, 345 deletions
diff --git a/core/search-component/.gitignore b/core/search-component/.gitignore
deleted file mode 100644
index 9220c11f..00000000
--- a/core/search-component/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/dist/
-/node_modules/
-/package-lock.json
diff --git a/core/search-component/build.gradle.kts b/core/search-component/build.gradle.kts
deleted file mode 100644
index ce747c5e..00000000
--- a/core/search-component/build.gradle.kts
+++ /dev/null
@@ -1,18 +0,0 @@
-plugins {
- id("com.moowork.node") version "1.3.1"
-}
-
-task("generateSearchFiles") {
- dependsOn("npm_install", "npm_run_build")
-}
-
-tasks {
- "npm_run_build" {
- inputs.dir("$projectDir/src/main/js/search/")
- inputs.files("$projectDir/package.json", "$projectDir/webpack.config.js")
- outputs.dir("$projectDir/dist/")
- }
- clean {
- delete = setOf("$projectDir/node_modules", "$projectDir/dist/", "$projectDir/package-lock.json")
- }
-} \ No newline at end of file
diff --git a/core/search-component/package.json b/core/search-component/package.json
deleted file mode 100644
index fa997c44..00000000
--- a/core/search-component/package.json
+++ /dev/null
@@ -1,80 +0,0 @@
-{
- "name": "search",
- "version": "1.0.0",
- "private": true,
- "config": {
- "components": "./src/main/js/search",
- "dist": "./dist"
- },
- "scripts": {
- "create-component": "yo @jetbrains/ring-ui:react --path $npm_package_config_components",
- "build": "webpack --mode=production --devtool sourcemap",
- "test": "karma start",
- "lint": "eslint . && npm run stylelint",
- "stylelint": "stylelint --ignore-path .gitignore **/*.css",
- "ci-test": "npm run lint && xvfb-maybe karma start --teamcity",
- "start": "webpack-dev-server -d --history-api-fallback --inline --hot --colors --port 9010"
- },
- "babel": {
- "presets": [
- [
- "@jetbrains/jetbrains",
- {
- "useBuiltIns": "usage"
- }
- ]
- ]
- },
- "dependencies": {
- "@babel/core": "^7.8.3",
- "@jetbrains/babel-preset-jetbrains": "^2.1.4",
- "@jetbrains/icons": "3.6.0",
- "@jetbrains/logos": "1.1.5",
- "@jetbrains/ring-ui": "2.1.16",
- "babel-loader": "^8.0.6",
- "copy-webpack-plugin": "^5.1.1",
- "css-loader": "^3.4.2",
- "json-loader": "^0.5.7",
- "postcss-import": "^12.0.1",
- "postcss-loader": "^3.0.0",
- "postcss-preset-env": "^6.7.0",
- "prop-types": "^15.7.2",
- "react": "^16.12.0",
- "react-dom": "^16.12.0",
- "redbox-react": "^1.6.0",
- "webpack": "^4.41.5",
- "webpack-cli": "^3.3.10",
- "webpack-dev-server": "^3.10.1"
- },
- "devDependencies": {
- "@jetbrains/generator-ring-ui": "2.0.53",
- "@jetbrains/eslint-config": "^4.0.6",
- "@jetbrains/stylelint-config": "^2.0.0",
- "babel-eslint": "^10.0.3",
- "chai": "^4.2.0",
- "chai-as-promised": "^7.1.1",
- "chai-dom": "^1.8.1",
- "chai-enzyme": "1.0.0-beta.1",
- "electron": "^7.1.9",
- "enzyme": "^3.11.0",
- "enzyme-adapter-react-16": "^1.15.2",
- "eslint": "^6.8.0",
- "karma": "^4.4.1",
- "karma-chai-plugins": "^0.9.0",
- "karma-electron": "^6.3.0",
- "karma-mocha": "^1.3.0",
- "karma-sourcemap-loader": "^0.3.7",
- "karma-teamcity-reporter": "^1.1.0",
- "karma-webpack": "^4.0.2",
- "mocha": "^6.2.2",
- "react-test-renderer": "^16.12.0",
- "sinon": "^8.0.4",
- "sinon-chai": "^3.4.0",
- "stylelint": "^12.0.1",
- "xvfb-maybe": "^0.2.1",
- "yo": "^3.1.1"
- },
- "engines": {
- "node": ">=8.0.0"
- }
-}
diff --git a/core/search-component/postcss.config.js b/core/search-component/postcss.config.js
deleted file mode 100644
index ce65774e..00000000
--- a/core/search-component/postcss.config.js
+++ /dev/null
@@ -1,17 +0,0 @@
-module.exports = () => ({
- plugins: [
- require('postcss-import'),
- require('postcss-preset-env')({
- features: {
- stage: 3, // See https://cssdb.org/#staging-process
- importFrom: require.resolve('@jetbrains/ring-ui/components/global/variables.css'),
- features: {
- 'nesting-rules': true,
- 'custom-properties': {
- preserve: true
- }
- }
- }
- })
- ]
-});
diff --git a/core/search-component/src/main/js/search/app-root.js b/core/search-component/src/main/js/search/app-root.js
deleted file mode 100644
index 5d650581..00000000
--- a/core/search-component/src/main/js/search/app-root.js
+++ /dev/null
@@ -1,47 +0,0 @@
-import React, {useRef, useState, useEffect} from 'react';
-import {WithFuzzySearchFilter} from './search';
-import './app.css';
-
-function useComponentVisible(initialIsVisible) {
- const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible);
- const ref = useRef(null);
-
- const handleHideDropdown = (event) => {
- if (event.key === "Escape") {
- setIsComponentVisible(false);
- }
- };
-
- const handleClickOutside = event => {
- if (ref.current && !ref.current.contains(event.target)) {
- setIsComponentVisible(false);
- }
- };
-
- useEffect(() => {
- document.addEventListener("keydown", handleHideDropdown, true);
- document.addEventListener("click", handleClickOutside, true);
- return () => {
- document.removeEventListener("keydown", handleHideDropdown, true);
- document.removeEventListener("click", handleClickOutside, true);
- };
- });
-
- return { ref, isComponentVisible, setIsComponentVisible };
-}
-
-export const AppRoot = () => {
- const {
- ref,
- isComponentVisible,
- setIsComponentVisible
- } = useComponentVisible(false);
-
- return <div ref={ref} className="search-content">
- {isComponentVisible && (<WithFuzzySearchFilter/>)}
- {!isComponentVisible && (
- <span onClick={() => setIsComponentVisible(true)}>
- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M19.64 18.36l-6.24-6.24a7.52 7.52 0 1 0-1.28 1.28l6.24 6.24zM7.5 13.4a5.9 5.9 0 1 1 5.9-5.9 5.91 5.91 0 0 1-5.9 5.9z"/></svg>
- </span>)}
- </div>
-} \ No newline at end of file
diff --git a/core/search-component/src/main/js/search/app.css b/core/search-component/src/main/js/search/app.css
deleted file mode 100644
index c51d3fe1..00000000
--- a/core/search-component/src/main/js/search/app.css
+++ /dev/null
@@ -1,21 +0,0 @@
-@import "@jetbrains/ring-ui/components/global/variables.css";
-
-html,
-.app-root {
- height: 100%;
-}
-
-.search-root {
- margin: 0;
- padding: 0;
-
- background: var(--ring-content-background-color);
-
- font-family: var(--ring-font-family);
- font-size: var(--ring-font-size);
- line-height: var(--ring-line-height);
-}
-
-.search-content {
- padding: 24px 41px;
-}
diff --git a/core/search-component/src/main/js/search/app.js b/core/search-component/src/main/js/search/app.js
deleted file mode 100644
index bceffa48..00000000
--- a/core/search-component/src/main/js/search/app.js
+++ /dev/null
@@ -1,41 +0,0 @@
-import React from 'react';
-import {render} from 'react-dom';
-import RedBox from 'redbox-react';
-
-import {AppRoot} from './app-root';
-import './app.css';
-
-const appEl = document.getElementById('searchBar');
-const rootEl = document.createElement('div');
-
-let renderApp = () => {
- render(
- <AppRoot/>,
- rootEl
- );
-};
-
-if (module.hot) {
- const renderAppHot = renderApp;
- const renderError = error => {
- render(
- <RedBox error={error}/>,
- rootEl
- );
- };
-
- renderApp = () => {
- try {
- renderAppHot();
- } catch (error) {
- renderError(error);
- }
- };
-
- module.hot.accept('./app-root', () => {
- setTimeout(renderApp);
- });
-}
-
-renderApp();
-appEl.appendChild(rootEl);
diff --git a/core/search-component/src/main/js/search/search.js b/core/search-component/src/main/js/search/search.js
deleted file mode 100644
index a742f11d..00000000
--- a/core/search-component/src/main/js/search/search.js
+++ /dev/null
@@ -1,52 +0,0 @@
-import React, {Component} from 'react';
-import Select from '@jetbrains/ring-ui/components/select/select';
-import '@jetbrains/ring-ui/components/input-size/input-size.scss';
-
-class WithFuzzySearchFilterComponent extends Component {
- constructor(props) {
- super(props);
- this.state = {selected: props.data[0]};
- }
-
- clearSelection = () => {
- this.setState({selected: null});
- };
-
- onSelect = option => {
- window.location.href = `${window.pathToRoot}${option.location}?query${option.name}`;
- this.setState({selected: option});
- debugger
- };
-
- render() {
- return (
- <div className="search-container">
- <div className="search">
- <Select
- selectedLabel="Search"
- label="Please type page name"
- filter={{fuzzy: true}}
- clear
- selected={this.state.selected}
- data={this.props.data}
- onSelect={this.onSelect}
- />
- </div>
- </div>
- );
- }
-}
-
-export const WithFuzzySearchFilter = () => {
- let data = [];
- if (window.pages) {
- data = window.pages.map((page, i) => ({
- ...page,
- label: page.name,
- key: i + 1,
- type: page.kind
- }));
- }
-
- return <WithFuzzySearchFilterComponent data={data}/>;
-};
diff --git a/core/search-component/stylelint.config.js b/core/search-component/stylelint.config.js
deleted file mode 100644
index 02b3f4ac..00000000
--- a/core/search-component/stylelint.config.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- extends: '@jetbrains/stylelint-config',
- rules: {}
-};
diff --git a/core/search-component/webpack.config.js b/core/search-component/webpack.config.js
deleted file mode 100644
index a7b503b6..00000000
--- a/core/search-component/webpack.config.js
+++ /dev/null
@@ -1,62 +0,0 @@
-const {join, resolve} = require('path');
-
-const ringUiWebpackConfig = require('@jetbrains/ring-ui/webpack.config');
-
-const pkgConfig = require('./package.json').config;
-
-const componentsPath = join(__dirname, pkgConfig.components);
-
-// Patch @jetbrains/ring-ui svg-sprite-loader config
-ringUiWebpackConfig.loaders.svgInlineLoader.include.push(
- require('@jetbrains/logos'),
- require('@jetbrains/icons')
-);
-
-const webpackConfig = () => ({
- entry: `${componentsPath}/app.js`,
- resolve: {
- mainFields: ['module', 'browser', 'main'],
- alias: {
- react: resolve('./node_modules/react'),
- 'react-dom': resolve('./node_modules/react-dom'),
- '@jetbrains/ring-ui': resolve('./node_modules/@jetbrains/ring-ui')
- }
- },
- output: {
- path: resolve(__dirname, pkgConfig.dist),
- filename: '[name].js',
- publicPath: '',
- devtoolModuleFilenameTemplate: '/[absolute-resource-path]'
- },
- module: {
- rules: [
- ...ringUiWebpackConfig.config.module.rules,
- {
- test: /\.css$/,
- include: componentsPath,
- use: [
- 'style-loader',
- {loader: 'css-loader'},
- {loader: 'postcss-loader'}
- ]
- },
- {
- test: /\.css$/,
- include: /node_modules/,
- exclude: ringUiWebpackConfig.componentsPath,
- use: ['style-loader', 'css-loader']
- },
- {
- test: /\.js$/,
- include: [componentsPath],
- loader: 'babel-loader?cacheDirectory'
- }
- ]
- },
- plugins: [],
- output: {
- path: __dirname + '/dist/'
- }
-});
-
-module.exports = webpackConfig;