lodash#kebabCase JavaScript Examples

The following examples show how to use lodash#kebabCase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.js    From hzero-front with Apache License 2.0 7 votes vote down vote up
/**
 * build the className by paths
 * 1. prefix side-layout in paths,
 * 2. let paths join with -
 * 3. call lodash.kebabCase
 * 4. return className
 * @param {...string} [paths] - the strings of className
 */
function defaultGetClassName(...paths) {
  return kebabCase(['hzero-side-line-layout', ...paths].join('-'));
}
Example #2
Source File: utils.js    From hzero-front with Apache License 2.0 7 votes vote down vote up
/**
 * build the className by paths
 * 1. prefix side-layout in paths,
 * 2. let paths join with -
 * 3. call lodash.kebabCase
 * 4. return className
 * @param {...string} [paths] - the strings of className
 */
function defaultGetClassName(...paths) {
  return kebabCase(['hzero-side-layout', ...paths].join('-'));
}
Example #3
Source File: utils.js    From hzero-front with Apache License 2.0 7 votes vote down vote up
/**
 * build the className by paths
 * 1. prefix hzero-side-layout-menu in paths,
 * 2. let paths join with -
 * 3. call lodash.kebabCase
 * 4. return className
 * @param {...string} [paths] - the strings of className
 */
function defaultGetClassName(...paths) {
  return kebabCase(['hzero-side-layout-menu', ...paths].join('-'));
}
Example #4
Source File: utils.js    From hzero-front with Apache License 2.0 7 votes vote down vote up
/**
 * build the className by paths
 * 1. prefix hzero-side-layout-menu in paths,
 * 2. let paths join with -
 * 3. call lodash.kebabCase
 * 4. return className
 * @param {...string} [paths] - the strings of className
 */
function defaultGetClassName(...paths) {
  return kebabCase(['hzero-side-layout-side-search', ...paths].join('-'));
}
Example #5
Source File: index.js    From elementor-editor-packages with GNU General Public License v3.0 6 votes vote down vote up
optionalScripts = Object.entries( scripts ).reduce(
	( current, [ key, script ] ) => {
		return {
			...current,
			[ kebabCase( key ) ]: script,
		};
	},
	{}
)
Example #6
Source File: PostTags.js    From paigeniedringhaus.com with MIT License 6 votes vote down vote up
PostTags = ({ tags }) => {
  const tagList = tags?.map((tag) => (
    <div key={tag} className={kebabCase(tag)}>
      {tag}
    </div>
  ));

  return (
    <div className="post-tag-container">
      {tags ? (
        <>
          <span>Tags: </span>
          {tagList}
        </>
      ) : null}
    </div>
  );
}
Example #7
Source File: config.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
templates = {
  DynamicForm: {
    templateType: 'DynamicForm',
    kebabCaseCode: kebabCase('DynamicForm'),
    config: [], // 默认的属性
    accepts: [
      fields.Input,
      fields.InputNumber,
      fields.TextArea,
      fields.DatePicker,
      fields.ValueList,
      fields.Lov,
      fields.Switch,
      fields.Checkbox,
    ], // tpl 的字段
    enabledFlag: 1, // 是否启用
    description: '表单', // intl 国际化 的默认值
  },
  DynamicTable: {
    templateType: 'DynamicTable',
    kebabCaseCode: kebabCase('DynamicTable'),
    config: [], // 默认的属性
    accepts: [fields.LinkButton, fields.ColumnField], // tpl 的字段
    enabledFlag: 1, // 是否启用
    description: '表格', // intl 国际化 的默认值
  },
  DynamicToolbar: {
    templateType: 'DynamicToolbar',
    kebabCaseCode: kebabCase('DynamicToolbar'),
    config: [], // 默认的属性
    accepts: [fields.Button], // tpl 的字段
    enabledFlag: 1, // 是否启用
    description: '按钮组', // intl 国际化 的默认值
  },
}
Example #8
Source File: index.js    From Blogs with MIT License 6 votes vote down vote up
TagsPage = ({ data }) => {
  return (
    <Layout>
      <section className="section">
        <Helmet title={`Categories | ${data.site.siteMetadata.title}`} />
        <div className="category-list-container mt-5">
          <h1>Categories</h1>
          <div className="category-list mt-4">
            {tagsdata.tagslist.map((tag) => (
              <Link
                to={"/categories/" + kebabCase(tag.name)}
                style={{
                  backgroundImage: `url('${tag.image}')`,
                }}
                className="category-list-category"
              >
                <h1 className="category-heading">{tag.name}</h1>
              </Link>
            ))}
          </div>
        </div>
      </section>
    </Layout>
  );
}
Example #9
Source File: blog-post.js    From gatsby-starter-netlify-cms with MIT License 6 votes vote down vote up
BlogPostTemplate = ({
  content,
  contentComponent,
  description,
  tags,
  title,
  helmet,
}) => {
  const PostContent = contentComponent || Content

  return (
    <section className="section">
      {helmet || ''}
      <div className="container content">
        <div className="columns">
          <div className="column is-10 is-offset-1">
            <h1 className="title is-size-2 has-text-weight-bold is-bold-light">
              {title}
            </h1>
            <p>{description}</p>
            <PostContent content={content} />
            {tags && tags.length ? (
              <div style={{ marginTop: `4rem` }}>
                <h4>Tags</h4>
                <ul className="taglist">
                  {tags.map((tag) => (
                    <li key={tag + `tag`}>
                      <Link to={`/tags/${kebabCase(tag)}/`}>{tag}</Link>
                    </li>
                  ))}
                </ul>
              </div>
            ) : null}
          </div>
        </div>
      </div>
    </section>
  )
}
Example #10
Source File: index.js    From gatsby-starter-netlify-cms with MIT License 6 votes vote down vote up
TagsPage = ({
  data: {
    allMarkdownRemark: { group },
    site: {
      siteMetadata: { title },
    },
  },
}) => (
  <Layout>
    <section className="section">
      <Helmet title={`Tags | ${title}`} />
      <div className="container content">
        <div className="columns">
          <div
            className="column is-10 is-offset-1"
            style={{ marginBottom: '6rem' }}
          >
            <h1 className="title is-size-2 is-bold-light">Tags</h1>
            <ul className="taglist">
              {group.map((tag) => (
                <li key={tag.fieldValue}>
                  <Link to={`/tags/${kebabCase(tag.fieldValue)}/`}>
                    {tag.fieldValue} ({tag.totalCount})
                  </Link>
                </li>
              ))}
            </ul>
          </div>
        </div>
      </div>
    </section>
  </Layout>
)
Example #11
Source File: category-list.js    From awesome-README-templates with MIT License 6 votes vote down vote up
render() {
    const { pageContext, data } = this.props;
    const categoryList = getCategoryList(data.allMarkdownRemark.edges);

    return (
      <Layout location={this.props.location} title="All Category Page">
        <div>
            <h3> Category List Page</h3>
            <ul>
            {
                Object.keys(categoryList).map((category, index) => {
                    return (<li key={index}>
                        <Link to={`/category/${kebabCase(category)}`}>
                            <p> {category} - {categoryList[category]} </p>
                        </Link>
                    </li>)
                })
            }
            </ul>
        </div>
      </Layout>
    )
  }
Example #12
Source File: theme.js    From atomize with MIT License 5 votes vote down vote up
themeProps = themePrefixes.map(kebabCase)
Example #13
Source File: format.jsx    From ResoBin with MIT License 5 votes vote down vote up
coursePageUrl = (code, title, hash) =>
  `/courses/${code}/${kebabCase(title)}${hash ? `#${hash}` : ''}`
Example #14
Source File: CoursePage.jsx    From ResoBin with MIT License 5 votes vote down vote up
CoursePage = () => {
  const location = useLocation()
  const { code, titleSlug } = useParams()
  const [courseData, setCourseData] = useState({})
  const [loading, setLoading] = useState(true)

  useEffect(() => {
    const getCourseData = async () => {
      try {
        setLoading(true)
        const response = await API.courses.read({ code })
        setCourseData(response)
      } catch (error) {
        toast({ status: 'error', content: error })
      } finally {
        setLoading(false)
      }
    }

    getCourseData()
  }, [code])

  if (loading) return <LoaderAnimation />
  if (isEmpty(courseData)) return <Navigate to="/404" replace />

  // ? redirect to canonical URL (eg: /courses/CL152/introduction-to-chemical-engineering)
  if (titleSlug !== kebabCase(courseData.title)) {
    const pathname = coursePageUrl(courseData.code, courseData.title)
    return <Navigate to={{ ...location, pathname }} replace />
  }

  return (
    <PageContainer>
      <Helmet>
        <title>{`${courseData.code}: ${courseData.title} - ResoBin`}</title>
        <meta property="description" content={courseData.description} />
      </Helmet>

      <CoursePageContainer courseData={courseData} />
    </PageContainer>
  )
}
Example #15
Source File: index.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
@Bind()
  initCKEditor() {
    const { onEditorChange = () => {}, content, readOnly, config = {}, style } = this.props;
    const { editorLoading } = this.state;
    if (!editorLoading && !window.CKEDITOR) {
      this.setState({
        editorLoading: true,
      });
    }
    getEditorNamespace(CKEditor.editorUrl)
      .then((CKEDITOR) => {
        const { HZERO_FILE, BKT_PUBLIC } = this.config;
        const { bucketName = BKT_PUBLIC, privateBucket = false } = this.props;
        const organizationId = getCurrentOrganizationId();
        // eslint-disable-next-line no-useless-catch
        try {
          const language = kebabCase(getCurrentLanguage() || 'zh_cn').toLocaleLowerCase();
          this.setState({
            editorLoading: false,
          });
          if (this.element) {
            this.editor = CKEDITOR.replace(this.element, {
              // extraPlugins:
              //   'image2',
              // codeSnippet_theme: 'solarized_dark',
              // customConfig: '/lib/ckeditor/config.js',
              removeButtons:
                'About,Flash,Save,Source,Form,Checkbox,Button,ShowBlocks,NewPage,Print,Language,Templates,CreateDiv,Radio,TextField,Textarea,Select,HiddenField',
              removePlugins: 'image,scayt,wsc,iframe',
              language,
              readOnly,
              height: 600,
              uploadUrl: `${HZERO_FILE}/v1${checkApiTenantPrefix()}/files/multipart`,
              filebrowserUploadUrl: `${HZERO_FILE}/v1${checkApiTenantPrefix()}/files/multipart`,
              disableNativeSpellChecker: false,
              font_names: `Arial/Arial, Helvetica, sans-serif; Comic Sans MS/Comic Sans MS;Courier New/Courier New;Georgia/Georgia;Lucida Sans Unicode/Lucida Sans Unicode;Times New Roman/Times New Roman, Times, serif;Verdana;宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;`,
              ...config,
            });
          }

          if (this.editor) {
            this.editor.filter = this.editor.filter || {};
            this._attachEventHandlers();
            if (content) {
              if (privateBucket) {
                const accessToken = getAccessToken();
                const imgReg = new RegExp(/<img\b.*?(?:>|\/>)/g);
                const newContent = content.replace(imgReg, (item) => {
                  const url = item.match(
                    /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\\.,@?^=%&:/~\\+#]*[\w\-\\@?^=%&/~\\+#])+([\S]+[.]*[\w\-\\@?^=%&/~\\+#])/
                  )
                    ? content.match(
                        /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\\.,@?^=%&:/~\\+#]*[\w\-\\@?^=%&/~\\+#])+([\S]+[.]*[\w\-\\@?^=%&/~\\+#])/
                      )[0]
                    : undefined;
                  const newUrl = `${HZERO_FILE}/v1/${organizationId}/files/redirect-url?bucketName=${bucketName}&access_token=${accessToken}&url=${encodeURIComponent(
                    url
                  )}`;
                  let replaceImg = item;
                  replaceImg = item.replace(
                    /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\\.,@?^=%&:/~\\+#]*[\w\-\\@?^=%&/~\\+#])+([\S]+[.]*[\w\-\\@?^=%&/~\\+#])/,
                    newUrl
                  );
                  return replaceImg;
                });
                this.editor.setData(newContent);
              } else {
                this.editor.setData(content);
              }
            }
            this._attachEventHandlers();
            if (isFunction(this.editor.on)) {
              this.editor.on('change', (evt) => {
                // getData() returns CKEditor's HTML content.
                onEditorChange(evt.editor.getData());
              });
              if (style) {
                this.editor.on('loaded', () => {
                  this.editor.container.setStyles(style);
                  this.editor.addCommand('insertFiles', {
                    exec: () => {
                      // const now = new Date();
                      // editor.insertHtml( `The current date and time is: <em>${ now.toString() }</em>` );
                      this.setState({
                        fileUploadModalVisible: true,
                      });
                    },
                  });
                  this.editor.ui.addButton('insertFilesBtn', {
                    label: intl.get('hzero.common.richTextEditor.insertFile').d('插入文件'),
                    command: 'insertFiles',
                    toolbar: 'insert',
                    icon: 'Templates',
                  });
                });
              }
              const accessToken = getAccessToken();
              this.editor.on(
                'fileUploadRequest',
                (evt) => {
                  const { bucketDirectory = 'editor' } = this.props;
                  const { fileLoader } = evt.data;
                  const { xhr } = fileLoader;
                  xhr.open('POST', fileLoader.uploadUrl, true);
                  if (accessToken) {
                    xhr.setRequestHeader('Authorization', `bearer ${accessToken}`);
                  }
                  xhr.setRequestHeader('Cache-Control', 'no-cache');
                  xhr.setRequestHeader('X-File-Name', this.fileName);
                  xhr.setRequestHeader('X-File-Size', this.total);

                  const formData = new FormData();
                  formData.append('file', fileLoader.file, fileLoader.fileName);
                  formData.append('bucketName', bucketName);
                  formData.append('directory', bucketDirectory);
                  formData.append('fileName', fileLoader.fileName);
                  xhr.send(formData);
                  evt.stop();
                },
                null,
                null,
                4
              );

              this.editor.on('fileUploadResponse', (evt) => {
                // Prevent the default response handler.
                evt.stop();
                // FIXME: @LiJun
                const { resolveImageUrl = () => {} } = this.props;
                const { fileLoader } = evt.data;
                const { xhr } = fileLoader;
                const res = xhr.responseText;
                if (isAbsoluteUrl(res)) {
                  // const organizationId = getCurrentOrganizationId();
                  // const params = qs.stringify({
                  //   url: res,
                  //   bucketName,
                  //   access_token: accessToken,
                  // });
                  // const imageUrl = `${HZERO_FILE}/v1/${organizationId}/files/redirect-url?${params}`;
                  const imageUrl = resolveImageUrl(res, bucketName);
                  let newUrl = res;
                  if (privateBucket) {
                    newUrl = `${HZERO_FILE}/v1/${organizationId}/files/redirect-url?bucketName=${bucketName}&access_token=${accessToken}&url=${encodeURIComponent(
                      res
                    )}`;
                  }
                  // eslint-disable-next-line no-param-reassign
                  evt.data.url = imageUrl && isAbsoluteUrl(imageUrl) ? imageUrl : newUrl;
                } else {
                  // eslint-disable-next-line no-param-reassign
                  evt.data.message = JSON.parse(res).message;
                }

                // Get XHR and response.
              });
            }
          }
        } catch (e) {
          throw e;
        }
      })
      .catch(window.console.error);
    // getEditorNamespace(CKEditor.editorUrl)
    //   .then(CKEDITOR => {
    //     // const constructor = this.props.type === 'inline' ? 'inline' : 'replace';

    //     this.setState({
    //       editorLoading: false,
    //     });

    //     const language = kebabCase(getCurrentLanguage() || 'zh_cn').toLocaleLowerCase();

    //     this.editor = CKEDITOR.replace(this.element, {
    //       editorName: 'richTextEditor',
    //       language,
    //       // customConfig: '',
    //       // Define the toolbar: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_toolbar
    //       // The full preset from CDN which we used as a base provides more features than we need.
    //       // Also by default it comes with a 3-line toolbar. Here we put all buttons in two rows.
    //       // toolbar: [{
    //       //     name: 'clipboard',
    //       //     items: ['PasteFromWord', '-', 'Undo', 'Redo'],
    //       //   },
    //       //   {
    //       //     name: 'basicstyles',
    //       //     items: ['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat', 'Subscript', 'Superscript'],
    //       //   },
    //       //   {
    //       //     name: 'links',
    //       //     items: ['Link', 'Unlink'],
    //       //   },
    //       //   {
    //       //     name: 'paragraph',
    //       //     items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote'],
    //       //   },
    //       //   {
    //       //     name: 'insert',
    //       //     items: ['Image', 'Table'],
    //       //   },
    //       //   {
    //       //     name: 'editing',
    //       //     items: ['Scayt'],
    //       //   },
    //       //   '/',

    //       //   {
    //       //     name: 'styles',
    //       //     items: ['Format', 'Font', 'FontSize'],
    //       //   },
    //       //   {
    //       //     name: 'colors',
    //       //     items: ['TextColor', 'BGColor', 'CopyFormatting'],
    //       //   },
    //       //   {
    //       //     name: 'align',
    //       //     items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
    //       //   },
    //       //   {
    //       //     name: 'document',
    //       //     items: ['Print', 'Source', 'NewPage'],
    //       //   },
    //       // ],

    //       // Since we define all configuration options here, let's instruct CKEditor to not load config.js which it does by default.
    //       // One HTTP request less will result in a faster startup time.
    //       // For more information check https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-customConfig

    //       // // Upload images to a CKFinder connector (note that the response type is set to JSON).
    //       // uploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json',

    //       // Configure your file manager integration. This example uses CKFinder 3 for PHP.
    //       // filebrowserBrowseUrl: '/apps/ckfinder/3.4.5/ckfinder.html',
    //       // filebrowserImageBrowseUrl: '/apps/ckfinder/3.4.5/ckfinder.html?type=Images',
    //       // filebrowserUploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Files',
    //       // filebrowserImageUploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Images',

    //       // Sometimes applications that convert HTML to PDF prefer setting image width through attributes instead of CSS styles.
    //       // For more information check:
    //       //  - About Advanced Content Filter: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_advanced_content_filter
    //       //  - About Disallowed Content: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_disallowed_content
    //       //  - About Allowed Content: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_allowed_content_rules
    //       disallowedContent: 'img{width,height,float}',
    //       extraAllowedContent: 'img[width,height,align];span{background}',

    //       // Enabling extra plugins, available in the full-all preset: https://ckeditor.com/cke4/presets
    //       extraPlugins:
    //         'colorbutton,font,justify,print,image2,codesnippet,placeholder,preview,bidi,emoji,find,selectall,copyformatting,newpage,uploadimage',
    //       codeSnippet_theme: 'solarized_dark',
    //       /** ********************* File management support ********************** */
    //       // In order to turn on support for file uploads, CKEditor has to be configured to use some server side
    //       // solution with file upload/management capabilities, like for example CKFinder.
    //       // For more information see https://ckeditor.com/docs/ckeditor4/latest/guide/dev_ckfinder_integration

    //       // Uncomment and correct these lines after you setup your local CKFinder instance.
    //       // filebrowserBrowseUrl: 'http://example.com/ckfinder/ckfinder.html',
    //       // filebrowserUploadUrl: 'http://example.com/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
    //       /** ********************* File management support ********************** */

    //       // Make the editing area bigger than default.
    //       height: 600,
    //       readOnly,
    //       // An array of stylesheets to style the WYSIWYG area.
    //       // Note: it is recommended to keep your own styles in a separate file in order to make future updates painless.
    //       // contentsCss: [
    //       //   // 'http://cdn.ckeditor.com/4.11.4/full-all/contents.css',
    //       //   'assets/css/pastefromword.css',
    //       // ],

    //       // This is optional, but will let us define multiple different styles for multiple editors using the same CSS file.
    //       bodyClass: 'document-editor',

    //       // Reduce the list of block elements listed in the Format dropdown to the most commonly used.
    //       format_tags: 'p;h1;h2;h3;pre',

    //       // Simplify the Image and Link dialog windows. The "Advanced" tab is not needed in most cases.
    //       removeDialogTabs: 'image:advanced;link:advanced',
    //       removeButtons: 'About',
    //       removePlugins: 'image',
    //       uploadUrl: `${HZERO_FILE}/v1/files/multipart`,
    //       filebrowserUploadUrl: `${HZERO_FILE}/v1/files/multipart`,
    //       // Define the list of styles which should be available in the Styles dropdown list.
    //       // If the "class" attribute is used to style an element, make sure to define the style for the class in "mystyles.css"
    //       // (and on your website so that it rendered in the same way).
    //       // Note: by default CKEditor looks for styles.js file. Defining stylesSet inline (as below) stops CKEditor from loading
    //       // that file, which means one HTTP request less (and a faster startup).
    //       // For more information see https://ckeditor.com/docs/ckeditor4/latest/guide/dev_styles
    //       stylesSet: [
    //         /* Inline Styles */
    //         {
    //           name: 'Marker',
    //           element: 'span',
    //           attributes: {
    //             class: 'marker',
    //           },
    //         },
    //         {
    //           name: 'Cited Work',
    //           element: 'cite',
    //         },
    //         {
    //           name: 'Inline Quotation',
    //           element: 'q',
    //         },

    //         /* Object Styles */
    //         {
    //           name: 'Special Container',
    //           element: 'div',
    //           styles: {
    //             padding: '5px 10px',
    //             background: '#eee',
    //             border: '1px solid #ccc',
    //           },
    //         },
    //         {
    //           name: 'Compact table',
    //           element: 'table',
    //           attributes: {
    //             cellpadding: '5',
    //             cellspacing: '0',
    //             border: '1',
    //             bordercolor: '#ccc',
    //           },
    //           styles: {
    //             'border-collapse': 'collapse',
    //           },
    //         },
    //         {
    //           name: 'Borderless Table',
    //           element: 'table',
    //           styles: {
    //             'border-style': 'hidden',
    //             'background-color': '#E6E6FA',
    //           },
    //         },
    //         {
    //           name: 'Square Bulleted List',
    //           element: 'ul',
    //           styles: {
    //             'list-style-type': 'square',
    //           },
    //         },
    //       ],
    //       ...config,
    //     });
    //     // CKEDITOR.plugins.add( 'customUploadFiles', {
    //     //   icons: 'templates',
    //     //   init: _editor => {
    //     //     _editor.addCommand( 'insertFiles', {
    //     //       exec: () => {
    //     //         // const now = new Date();
    //     //         // editor.insertHtml( `The current date and time is: <em>${ now.toString() }</em>` );
    //     //         this.setState({
    //     //           fileUploadModalVisible: true,
    //     //         });
    //     //       },
    //     //     });
    //     //     _editor.ui.addButton( 'insertFilesBtn', {
    //     //         label: intl.get('hzero.common.richTextEditor.insertFile').d('插入文件'),
    //     //         command: 'insertFiles',
    //     //         toolbar: 'insert',
    //     //         icon: 'Templates',
    //     //     });
    //     //   },
    //     // });

    //     const { editor } = this;
    //     if (editor) {
    //       // editor.addCommand('insertFiles', {
    //       //   exec: () => {
    //       //     // const now = new Date();
    //       //     // editor.insertHtml( `The current date and time is: <em>${ now.toString() }</em>` );
    //       //     this.setState({
    //       //       fileUploadModalVisible: true,
    //       //     });
    //       //   },
    //       // });
    //       // editor.ui.addButton('insertFilesBtn', {
    //       //   label: intl.get('hzero.common.richTextEditor.insertFile').d('插入文件'),
    //       //   command: 'insertFiles',
    //       //   toolbar: 'insert',
    //       //   icon: 'Templates',
    //       // });

    //       editor.on(
    //         'fileUploadRequest',
    //         evt => {
    //           const { bucketName = 'static-text' } = this.props;
    //           const { fileLoader } = evt.data;
    //           const { xhr } = fileLoader;
    //           const accessToken = getAccessToken();
    //           xhr.open('POST', fileLoader.uploadUrl, true);
    //           if (accessToken) {
    //             xhr.setRequestHeader('Authorization', `bearer ${accessToken}`);
    //           }
    //           xhr.setRequestHeader('Cache-Control', 'no-cache');
    //           xhr.setRequestHeader('X-File-Name', this.fileName);
    //           xhr.setRequestHeader('X-File-Size', this.total);

    //           const formData = new FormData();
    //           formData.append('file', fileLoader.file, fileLoader.fileName);
    //           formData.append('bucketName', bucketName);
    //           formData.append('fileName', fileLoader.fileName);
    //           xhr.send(formData);
    //           evt.stop();
    //         },
    //         null,
    //         null,
    //         4
    //       );
    //       editor.on('fileUploadResponse', evt => {
    //         // Prevent the default response handler.
    //         evt.stop();
    //         const { bucketName = 'static-text' } = this.props;
    //         const { fileLoader } = evt.data;
    //         const { xhr } = fileLoader;
    //         const res = xhr.responseText;
    //         if (isAbsoluteUrl(res)) {
    //           // eslint-disable-next-line no-param-reassign
    //           evt.data.url = getAttachmentUrl(res, bucketName);
    //         } else {
    //           // eslint-disable-next-line no-param-reassign
    //           evt.data.message = JSON.parse(res).message;
    //         }

    //         // Get XHR and response.
    //       });

    //       this._attachEventHandlers();

    //       // if ( this.props.style && this.props.type !== 'inline' ) {
    //       // 	editor.on( 'loaded', () => {
    //       // 		editor.container.setStyles( this.props.style );
    //       // 	} );
    //       // }

    //       if (content) {
    //         editor.setData(content);
    //       }

    //       editor.on('change', evt => {
    //         // getData() returns CKEditor's HTML content.
    //         onChange(evt.editor.getData());
    //       });
    //     }

    //   })
    //   .catch(window.console.error);
  }
Example #16
Source File: blog-post.js    From Blogs with MIT License 4 votes vote down vote up
BlogPostTemplate = ({
  content,
  contentComponent,
  description,
  tags,
  title,
  helmet,
  author,
  date,
}) => {
  const PostContent = contentComponent || Content;

  return (
    <section
      className="section"
      style={{
        zIndex: "-1",
        marginTop: "0 !important",
        background:
          "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAilBMVEX////+/v4AAAArKyv5+fnz8/MtLS339/fp6en7+/vl5eUkJCQoKCjx8fEWFhYdHR0ODg6srKyfn5/f39+5ublNTU3m5uZeXl7R0dEfHx/V1dW/v790dHTZ2dkZGRmzs7OQkJA+Pj5+fn41NTVoaGiampqKiopDQ0PGxsaMjIxra2tZWVlKSkqlpaWWb1KtAAAgAElEQVR4nLVdCZeyvA6GuKEsgsiIgsqqjOj//3uXsnZJAef9bs6ZER5CmwJN2zRNFaUjtaL2MIA7DXeHG1i0tF4vbkdFIIqXQ08WgorMyX6lIEk0vI9znff5gaYQ3E5jQnD0ARfFU6Mt4OIc4xwSMiGZxZdYK9ml5clqMjfeOEMI4yVT6Z/MxtAK19s3aJ02Cv+w20fHPcHmtIADlp3wtB+2qYgJk3/m87xuS6hv6Ox6Ngd8mRAMQo6W65ItWXe9/k6qL9R+cNeZYwyNF5LsWLQpISNgc+wudJJxTbaLiFaxwEOhbuMKyJ6oaYqgFTkWKaBh91WwT17lROUTdqqajRaLRSNbQ1BF8cEymodbkXXEU3gzVQHPpDv9QIF+hL5NqmDqMsxICiKqkdzHeJufCDQErciNYjgbTRHPv3wKLdcLTksBxSunaZ9QXKuUqVVKlcEI3ckzGyfV/ZQ67KTXr7+pfTaqIuqejOUXPggaJb+BUM4QtogIqmIvbF4pqoqWfIILX2yuMciaBNEmgjzmVZCkAPrrPuQr8qp+YlhGugZEtJp3q2cIGn2iFPi27R2LchB6giOCPhCyn68HrTBZ6XbHLlMsWd+rEnj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qUSzvsFjNbWezUlCR1CRrBu8zC5DeS+tOqcrSjXaKT2bPDqBODSoz1Yjrq4Dvnvpphdw1TnNVQ8qUJKJXEKOqW75SEC6ir8h8NbAcw8uISJGBdxsxPmxO23F9Vt0NQu3bYzUu9SQDIqop/sYOZa0/KO5XEb1e7zBP4kvqskDjzyCwUYVbpkG9mSfsA93TxIBZbUjadCTTBQgcPwEgKdAzHE7Z5YM2pKi/i6YLaq2jXgnyIKMXyOmd4IaFJ5uufAth9JjghRgxsMdWHM9uVzwpHBGjDQSEqmUS8bY6ucalxt/W0KVsRv2otqMPUG+eVHFZqYNh5uFJcBvfK/wfGGdZSHcbf2gAAAABJRU5ErkJggg=='), rgb(245,245,245)",
      }}
    >
      {helmet || ""}
      <div style={{ backgroundColor: "rgba(205,205,205,0.7)" }}>
        <div className="container pt-3 pb-3">
          <div className="">
            <div
              className="card"
              style={{
                height: "auto",
                margin: "1% 0",
                borderRadius: "20px",
                zIndex: "10",
              }}
            >
              <h1
                className="is-size-2 has-text-weight-bold is-bold-light blog-title"
                style={{
                  fontSize: "3em",
                }}
              >
                {title}
                {date && (
                  <span
                    style={{
                      fontSize: "0.5em",
                      fontWeight: "normal",
                      color: "#24242433",
                    }}
                    className="ml-2"
                  >
                    {date}
                  </span>
                )}
              </h1>
              {author && (
                <div
                  style={{
                    fontSize: "1.8em",
                    fontWeight: "bold",
                    color: "#00bf8f",
                  }}
                  className="mr-3"
                >
                  {author}
                </div>
              )}

              <p className="blog-description">{description}</p>
              {tags && tags.length ? (
                <div>
                  {/* <h4>Tags: </h4> */}
                  <ul className="taglist" style={{ listStyleType: "none" }}>
                    {tags.map((tag) => (
                      <Badge
                        style={{
                          padding: "5px 10px",
                          margin: "5px",
                          background: "#00c18f",
                        }}
                        key={tag + `tag`}
                      >
                        <Link
                          className="links-tags"
                          to={`/categories/${kebabCase(tag)}/`}
                        >
                          {tag}
                        </Link>
                      </Badge>
                    ))}
                  </ul>
                </div>
              ) : null}
              <PostContent content={content} className="blog-post-content" />

              <div
                className="btn btn-secondary mb-2"
                style={{ width: "120px" }}
              >
                {/* eslint-disable-next-line */}
                <div className="links" onClick={() => window.history.back()}>
                  <ChevronDoubleLeft /> Go Back
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}
Example #17
Source File: config.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
fields = {
  // form
  Input: {
    componentType: 'Input',
    kebabCaseCode: kebabCase('Input'),
    config: [], // 默认属性
    fieldName: 'input',
    fieldLabel: '文本', // intl 国际化 的默认值
    description: '文本', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  InputNumber: {
    componentType: 'InputNumber',
    kebabCaseCode: kebabCase('InputNumber'),
    config: [], // 默认属性
    fieldName: 'inputNumber',
    fieldLabel: '数值框', // intl 国际化 的默认值
    description: '数值框', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  TextArea: {
    componentType: 'TextArea',
    kebabCaseCode: kebabCase('TextArea'),
    config: [], // 默认属性
    fieldName: 'textArea',
    fieldLabel: '多行文本', // intl 国际化 的默认值
    description: '多行文本', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  DatePicker: {
    componentType: 'DatePicker',
    kebabCaseCode: kebabCase('DatePicker'),
    config: [], // 默认属性
    fieldName: 'datePicker',
    fieldLabel: '日期', // intl 国际化 的默认值
    description: '日期', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  ValueList: {
    componentType: 'ValueList',
    kebabCaseCode: kebabCase('ValueList'),
    config: [], // 默认属性
    fieldName: 'valueList',
    fieldLabel: '下拉框', // intl 国际化 的默认值
    description: '下拉框', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  Lov: {
    componentType: 'Lov',
    kebabCaseCode: kebabCase('Lov'),
    config: [], // 默认属性
    fieldName: 'lov',
    fieldLabel: 'Lov', // intl 国际化 的默认值
    description: 'Lov', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  Switch: {
    componentType: 'Switch',
    kebabCaseCode: kebabCase('Switch'),
    config: [], // 默认属性
    fieldName: 'switch',
    fieldLabel: '开关', // intl 国际化 的默认值
    description: '开关', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  Checkbox: {
    componentType: 'Checkbox',
    kebabCaseCode: kebabCase('Checkbox'),
    config: [], // 默认属性
    fieldName: 'checkbox',
    fieldLabel: 'checkbox', // intl 国际化 的默认值
    description: 'checkbox', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  // toolbar
  Button: {
    componentType: 'Button',
    kebabCaseCode: kebabCase('Button'),
    config: [], // 默认属性
    fieldName: 'button',
    fieldLabel: '按钮', // intl 国际化 的默认值
    description: '按钮', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  // table
  LinkButton: {
    componentType: 'LinkButton',
    kebabCaseCode: kebabCase('LinkButton'),
    config: [], // 默认属性
    fieldName: 'linkButton',
    fieldLabel: '行内按钮', // intl 国际化 的默认值
    description: '行内按钮', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
  ColumnField: {
    componentType: 'ColumnField',
    kebabCaseCode: kebabCase('ColumnField'),
    config: [], // 默认属性
    fieldName: 'columnField',
    fieldLabel: '列字段', // intl 国际化 的默认值
    description: '列字段', // intl 国际化 的默认值
    requiredFlag: 0, // 是否必输
    enabledFlag: 1, // 是否启用
    visibleFlag: 1, // 是否显示(不隐藏)
  },
}
Example #18
Source File: ContributeForm.jsx    From ResoBin with MIT License 4 votes vote down vote up
ContributeForm = ({ fileItem, handleUpload, handleDelete }) => {
  const { getQueryString } = useQueryString()
  const course = getQueryString('course')

  const tagOptions = tags.resourceTags.map((tag) => ({
    label: tag,
    value: kebabCase(tag),
  }))

  const courseListMinified = useSelector(selectCourseListMinified)
  const courseOptions = courseListMinified.map(({ code, title }) => ({
    label: `${code}: ${title}`,
    value: code,
  }))

  const [form] = Form.useForm()

  return (
    <Form
      form={form}
      name="contribute"
      onFinish={handleUpload}
      layout="vertical"
      initialValues={{ ...fileItem.details, course }}
    >
      <Form.Item
        name="title"
        rules={[
          { required: true, message: 'Title is required.' },
          { min: 5, message: 'Title must be atleast 5 characters.' },
          { max: 100, message: 'Title must be atmost 100 characters.' },
        ]}
      >
        <Input placeholder="Title" />
      </Form.Item>

      <Form.Item
        name="author"
        rules={[{ max: 255, message: 'Author must be atmost 255 characters.' }]}
      >
        <Input placeholder="Author" />
      </Form.Item>

      <Form.Item
        name="description"
        rules={[
          { max: 500, message: 'Description must be atmost 500 characters.' },
        ]}
      >
        <Input.TextArea
          autoSize={{ minRows: 1, maxRows: 10 }}
          placeholder="Description"
        />
      </Form.Item>

      <Form.Item
        name="course"
        rules={[{ required: true, message: 'Course is required.' }]}
      >
        <Select showSearch placeholder="Course" options={courseOptions} />
      </Form.Item>

      <Form.Item name="tags">
        <Select
          mode="tags"
          placeholder="Add tags"
          showArrow
          tokenSeparators={[',']}
          options={tagOptions}
        />
      </Form.Item>

      <ButtonContainer>
        <ButtonSquare
          type="primary"
          htmlType="submit"
          loading={fileItem.status === 'uploading'}
        >
          Submit
        </ButtonSquare>

        <Button
          type="primary"
          danger
          onClick={handleDelete}
          hidden={fileItem.status === 'uploading'}
          style={{ borderRadius: '0.5rem' }}
        >
          Delete
        </Button>
      </ButtonContainer>
    </Form>
  )
}
Example #19
Source File: CourseFinderFilterForm.jsx    From ResoBin with MIT License 4 votes vote down vote up
CourseFinderFilterForm = ({ setLoading }) => {
  const { deleteQueryString, getQueryString, setQueryString } = useQueryString()
  const [form] = Form.useForm()

  const handleFilterClear = (formField, qsFields) => () => {
    const defaultInitialValues = {
      semester: [],
      credits: [2, 9],
      halfsem: false,
      running: false,
      department: [],
      tags: [],
      slots: [],
    }

    form.setFieldsValue({
      [formField]: defaultInitialValues[formField],
    })

    deleteQueryString(...qsFields, 'p')
  }

  const handleFilterUpdate = (_, allFields) => {
    setLoading(true)
    deleteQueryString('p')

    if (allFields?.credits?.[0] !== 2)
      setQueryString('credits_min', allFields.credits[0])
    else deleteQueryString('credits_min')

    if (allFields?.credits?.[1] !== 9)
      setQueryString('credits_max', allFields.credits[1])
    else deleteQueryString('credits_max')

    setQueryString('department', allFields.department)
    setQueryString('semester', allFields.semester)
    setQueryString('tags', allFields.tags)
    setQueryString('slots', allFields.slots)

    if (allFields.halfsem) setQueryString('halfsem', 'true')
    else deleteQueryString('halfsem')

    if (allFields.running) setQueryString('running', 'true')
    else deleteQueryString('running')
  }

  const semesterOptions = [
    { label: 'Autumn', value: 'autumn' },
    { label: 'Spring', value: 'spring' },
  ]

  const departmentOptions = useSelector(selectDepartments)?.map(
    (department) => ({
      label: department.name,
      value: department.slug,
    })
  )

  const tagOptions = tags.courseTags.map((tag) => ({
    label: tag,
    value: kebabCase(tag),
  }))

  const slotOptions = Object.keys(slots).map((slot) => ({
    label: slot,
    value: slot,
  }))

  return (
    <Form
      form={form}
      name="course_filter"
      layout="vertical"
      onValuesChange={handleFilterUpdate}
      initialValues={{
        semester: getQueryString('semester')?.split(',') ?? [],
        halfsem: getQueryString('halfsem') === 'true',
        running: getQueryString('running') === 'true',
        credits: [
          parseInt(getQueryString('credits_min') ?? 2, 10),
          parseInt(getQueryString('credits_max') ?? 9, 10),
        ],
        department: getQueryString('department')?.split(',') ?? [],
        tags: getQueryString('tags')?.split(',') ?? [],
        slots: getQueryString('slots')?.split(',') ?? [],
      }}
      style={{ gap: '1rem', padding: '0 0.5rem' }}
    >
      <CourseFinderFilterItem
        label="Running courses only"
        onClear={handleFilterClear('running', ['running'])}
        content={
          <Form.Item name="running" valuePropName="checked">
            <Switch />
          </Form.Item>
        }
      />

      <div>
        <CourseFinderFilterItem
          label="Departments"
          onClear={handleFilterClear('department', ['department'])}
        />
        <Form.Item name="department">
          <Select
            mode="multiple"
            options={departmentOptions}
            placeholder="Type something..."
            showArrow
          />
        </Form.Item>
      </div>

      <div>
        <CourseFinderFilterItem
          label={
            <>
              Slots <b>(beta)</b>
            </>
          }
          onClear={handleFilterClear('slots', ['slots'])}
        />
        <Form.Item name="slots">
          <Select
            mode="multiple"
            options={slotOptions}
            placeholder="Type something..."
            showArrow
          />
        </Form.Item>
      </div>

      <div>
        <CourseFinderFilterItem
          label="Semesters"
          onClear={handleFilterClear('semester', ['semester'])}
        />
        <Form.Item name="semester">
          <Checkbox.Group
            options={semesterOptions}
            style={{ display: 'flex', gap: '1rem' }}
          />
        </Form.Item>
      </div>

      <CourseFinderFilterItem
        label="Half semester only"
        onClear={handleFilterClear('halfsem', ['halfsem'])}
        content={
          <Form.Item name="halfsem" valuePropName="checked">
            <Switch />
          </Form.Item>
        }
      />

      <div>
        <CourseFinderFilterItem
          label="Credits"
          onClear={handleFilterClear('credits', ['credits_min', 'credits_max'])}
        />
        <Form.Item name="credits">
          <Slider
            range
            min={2}
            step={null}
            max={9}
            marks={{
              2: '<3',
              3: '3',
              4: '4',
              5: '5',
              6: '6',
              7: '7',
              8: '8',
              9: '>8',
            }}
            tipFormatter={null}
            style={{ marginRight: '1rem', marginLeft: '0.5rem' }}
          />
        </Form.Item>
      </div>

      <div>
        <CourseFinderFilterItem
          label="Tags"
          onClear={handleFilterClear('tags', ['tags'])}
        />
        <Form.Item name="tags">
          <Select
            mode="multiple"
            options={tagOptions}
            placeholder="Select something..."
            showArrow
          />
        </Form.Item>
      </div>
    </Form>
  )
}
Example #20
Source File: CourseResourceItemEditModal.jsx    From ResoBin with MIT License 4 votes vote down vote up
CourseResourceItemEditModal = ({
  visible,
  onEdit,
  onCancel,
  initialValues,
}) => {
  const [form] = Form.useForm()

  const handleOk = async () => {
    try {
      const values = await form.validateFields()
      onEdit(values)
    } catch (error) {
      toast({ status: 'error', content: 'Check your inputs' })
    }
  }

  const tagOptions = tags.resourceTags.map((tag) => ({
    label: tag,
    value: kebabCase(tag),
  }))

  const courseOptions = useSelector(selectCourseListMinified)?.map(
    ({ code, title }) => ({
      label: `${code}: ${title}`,
      value: code,
    })
  )

  return (
    <Modal
      visible={visible}
      title="Edit your upload"
      okText="Save"
      cancelText="Cancel"
      onCancel={onCancel}
      onOk={handleOk}
    >
      <Form
        form={form}
        layout="vertical"
        name="editResource"
        initialValues={initialValues}
        onFinish={onEdit}
      >
        <Form.Item
          name="course"
          label="Course"
          rules={[
            {
              required: true,
              message: 'Course is necessary',
            },
          ]}
        >
          <Select showSearch placeholder="Course" options={courseOptions} />
        </Form.Item>

        <Form.Item
          name="title"
          label="Title"
          rules={[
            {
              required: true,
              message: 'Title is necessary',
            },
          ]}
        >
          <Input />
        </Form.Item>

        <Form.Item name="description" label="Description">
          <Input.TextArea />
        </Form.Item>

        <Form.Item name="tags" label="Tags">
          <Select
            mode="tags"
            placeholder="Add tags"
            showArrow
            tokenSeparators={[',']}
            options={tagOptions}
          />
        </Form.Item>
      </Form>
    </Modal>
  )
}