mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 14:59:07 +00:00
Created Carret compo in helper plugin
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
25ddf4604c
commit
efd46a117f
@ -1,118 +0,0 @@
|
||||
/**
|
||||
* app.js
|
||||
*
|
||||
* This is the entry file for the application,
|
||||
* only setup and plugin code.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
// Don't move this line!
|
||||
// import './public-path.js'; // eslint-disable-line import/extensions
|
||||
|
||||
import React from 'react';
|
||||
// import Loadable from 'react-loadable';
|
||||
// import LoadingIndicatorPage from './components/LoadingIndicatorPage';
|
||||
import { translationMessages } from './i18n';
|
||||
import App from 'containers/App';
|
||||
|
||||
// const LoadableApp = Loadable({
|
||||
// loader: () => import('containers/App'),
|
||||
// loading: LoadingIndicatorPage,
|
||||
// });
|
||||
|
||||
// const tryRequireRoot = source => {
|
||||
// try {
|
||||
// return require('../../../../admin/src/' + source + '.js').default; // eslint-disable-line prefer-template
|
||||
// } catch (err) {
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
|
||||
const layout = (() => {
|
||||
try {
|
||||
return require('../../../../config/layout.js');
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
const injectedComponents = (() => {
|
||||
try {
|
||||
return require('injectedComponents').default;
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
})();
|
||||
|
||||
// Plugin identifier based on the package.json `name` value
|
||||
const pluginPkg = require('../../../../package.json');
|
||||
const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');
|
||||
const pluginName = pluginPkg.strapi.name;
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
const apiUrl = `${strapi.backendURL}/${pluginId}`;
|
||||
const router = strapi.router;
|
||||
|
||||
// Create redux store with Strapi admin history
|
||||
// const store = configureStore({}, strapi.router, pluginName);
|
||||
const store = strapi.store;
|
||||
|
||||
// Define the plugin root component
|
||||
function Comp(props) {
|
||||
return <App {...props} />;
|
||||
}
|
||||
|
||||
// Hot reloadable translation json files
|
||||
if (module.hot) {
|
||||
// modules.hot.accept does not accept dynamic dependencies,
|
||||
// have to be constants at compile-time
|
||||
module.hot.accept('./i18n', () => {
|
||||
if (strapi) {
|
||||
System.import('./i18n').then(result => {
|
||||
const translationMessagesUpdated = result.translationMessages;
|
||||
strapi
|
||||
.refresh(pluginId)
|
||||
.translationMessages(translationMessagesUpdated);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Require the Initializer component
|
||||
const initializer = (() => {
|
||||
try {
|
||||
return require('../../../../admin/src/initializer.js');
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
// Require the plugin's lifecycle
|
||||
const lifecycles = (() => {
|
||||
try {
|
||||
return require('../../../../admin/src/lifecycles.js');
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
// Register the plugin.
|
||||
strapi.registerPlugin({
|
||||
blockerComponent: null,
|
||||
blockerComponentProps: {},
|
||||
description: pluginDescription,
|
||||
icon: pluginPkg.strapi.icon,
|
||||
id: pluginId,
|
||||
initializer,
|
||||
injectedComponents,
|
||||
layout,
|
||||
lifecycles,
|
||||
leftMenuLinks: [],
|
||||
leftMenuSections: [],
|
||||
mainComponent: Comp,
|
||||
name: pluginPkg.strapi.name,
|
||||
preventComponentRendering: false,
|
||||
translationMessages,
|
||||
});
|
||||
|
||||
// Export store
|
||||
export { store, apiUrl, pluginId, pluginName, pluginDescription, router };
|
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Carret as Base } from '@buffetjs/icons';
|
||||
|
||||
const Carret = styled(({ isUp, ...rest }) => <Base {...rest} />)`
|
||||
margin-left: 5px;
|
||||
${({ isUp }) =>
|
||||
isUp &&
|
||||
`
|
||||
transform: rotateZ(180deg);
|
||||
`}
|
||||
`;
|
||||
|
||||
export default Carret;
|
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* i18n.js
|
||||
*
|
||||
* This will setup the i18n language files and locale data for your plugin.
|
||||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable no-console */
|
||||
import { reduce } from 'lodash';
|
||||
|
||||
// Plugin identifier based on the package.json `name` value
|
||||
const pluginPkg = require('../../../../package.json');
|
||||
|
||||
const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');
|
||||
|
||||
/**
|
||||
* Add plugin identifier as translation message prefix,
|
||||
* in order to avoid confusion and errors when many
|
||||
* plugins are installed.
|
||||
*
|
||||
* @param messages
|
||||
*/
|
||||
const formatMessages = messages =>
|
||||
reduce(
|
||||
messages,
|
||||
(result, value, key) => {
|
||||
result[`${pluginId}.${key}`] = value;
|
||||
|
||||
return result;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
/**
|
||||
* Try to require translation file.
|
||||
*
|
||||
* @param language {String}
|
||||
*/
|
||||
const requireTranslations = language => {
|
||||
try {
|
||||
return require(`translations/${language}.json`); // eslint-disable-line global-require
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Unable to load "${language}" translation for the plugin ${pluginId}. Please make sure "${language}.json" file exists in "pluginPath/admin/src/translations" folder.`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dynamically generate `translationsMessages object`.
|
||||
*/
|
||||
|
||||
const translationMessages = reduce(
|
||||
strapi.languages,
|
||||
(result, language) => {
|
||||
result[language] = formatMessages(requireTranslations(language));
|
||||
|
||||
return result;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
export { translationMessages };
|
@ -11,6 +11,7 @@ export { default as BaselineAlignement } from './components/BaselineAlignement';
|
||||
export { default as BlockerComponent } from './components/BlockerComponent';
|
||||
export { default as Button } from './components/Button';
|
||||
export { default as ButtonModal } from './components/ButtonModal';
|
||||
export { default as Carret } from './components/Carret';
|
||||
export { default as CircleButton } from './components/CircleButton';
|
||||
export { default as ContainerFluid } from './components/ContainerFluid';
|
||||
export { default as ErrorBoundary } from './components/ErrorBoundary';
|
||||
|
@ -1,13 +0,0 @@
|
||||
// const pluginPkg = require('../../../../package.json');
|
||||
// const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');
|
||||
// const publicPath = `plugins/${pluginId}/`;
|
||||
|
||||
// __webpack_public_path__ = (() => {
|
||||
// if (window.location.port === '4000') {
|
||||
// return `${window.location.origin}/`;
|
||||
// } else if (strapi.mode === 'backend') {
|
||||
// return `${strapi.backendURL}/${publicPath}`;
|
||||
// }
|
||||
|
||||
// return `${(strapi.remoteURL).replace(window.location.origin, '')}/${publicPath}`;
|
||||
// })();
|
@ -8,7 +8,6 @@ const Arrow = styled(({ isUp, ...rest }) => <Carret {...rest} />)`
|
||||
isUp &&
|
||||
`
|
||||
transform: rotateZ(180deg);
|
||||
|
||||
`}
|
||||
`;
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
import React, { memo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useGlobalContext } from 'strapi-helper-plugin';
|
||||
import { Carret, useGlobalContext } from 'strapi-helper-plugin';
|
||||
import { useListView } from '../../../hooks';
|
||||
import Arrow from './Arrow';
|
||||
|
||||
const Header = ({ fieldSchema: { type }, metadatas: { label, sortable, mainField }, name }) => {
|
||||
const { _sort, firstSortableHeader, setQuery } = useListView();
|
||||
@ -37,7 +36,7 @@ const Header = ({ fieldSchema: { type }, metadatas: { label, sortable, mainField
|
||||
<th onClick={handleClick}>
|
||||
<span className={sortable ? 'sortable' : ''}>
|
||||
{label}
|
||||
{sortBy === sortField && <Arrow fill="#212529" isUp={sortOrder === 'ASC' && 'isAsc'} />}
|
||||
{sortBy === sortField && <Carret fill="#212529" isUp={sortOrder === 'ASC' && 'isAsc'} />}
|
||||
</span>
|
||||
</th>
|
||||
);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import React, { memo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Flex, Padded, Picker } from '@buffetjs/core';
|
||||
import { Carret } from '@buffetjs/icons';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { Carret } from 'strapi-helper-plugin';
|
||||
import Fields from './Fields';
|
||||
import Header from './Header';
|
||||
import Wrapper from './Wrapper';
|
||||
@ -19,7 +19,7 @@ const FieldPicker = ({ displayedHeaders, items, onChange, onClickReset, slug })
|
||||
<FontAwesomeIcon icon="cog" style={{ marginRighte: 10 }} />
|
||||
</div>
|
||||
<Padded left size="sm">
|
||||
<Carret fill={isOpen ? '#007eff' : '#292b2c'} />
|
||||
<Carret fill={isOpen ? '#007eff' : '#292b2c'} isUp={isOpen} />
|
||||
</Padded>
|
||||
</Flex>
|
||||
)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user