diff --git a/app/assets/stylesheets/shared_styles/constants/fonts.scss b/app/assets/stylesheets/shared_styles/constants/fonts.scss index 10b034128..e59c450e1 100644 --- a/app/assets/stylesheets/shared_styles/constants/fonts.scss +++ b/app/assets/stylesheets/shared_styles/constants/fonts.scss @@ -51,6 +51,30 @@ $sn-icon-check: "\e95f"; } } +.sn-checkbox-icon { + background-position: center center; + background-repeat: no-repeat; + background-size: contain; + height: 1rem; + width: 1rem; + + &.unchecked { + background-image: asset-url("checkbox/default.svg"); + } + + &.checked { + background-image: asset-url("checkbox/checked.svg"); + } + + &.disabled { + background-image: asset-url("checkbox/disabled.svg"); + } + + &.indeterminate { + background-image: asset-url("checkbox/indeterminate.svg"); + } +} + @mixin font-h1 { font-size: 24px; font-weight: bold; diff --git a/app/controllers/design_elements_controller.rb b/app/controllers/design_elements_controller.rb new file mode 100644 index 000000000..c74bfe83f --- /dev/null +++ b/app/controllers/design_elements_controller.rb @@ -0,0 +1,19 @@ +class DesignElementsController < ApplicationController + def index + end + + def test_select + render json: { data: [ + ['1', 'One'], + ['2', 'Two'], + ['3', 'Three'], + ['4', 'Four'], + ['5', 'Five'], + ['6', 'Six'], + ['7', 'Seven'], + ['8', 'Eight'], + ['9', 'Nine'], + ['10', 'Ten'] + ].select { |item| item[1].downcase.include?(params[:query].downcase) } } + end +end diff --git a/app/javascript/packs/vue/design_system/select.js b/app/javascript/packs/vue/design_system/select.js new file mode 100644 index 000000000..174e331e1 --- /dev/null +++ b/app/javascript/packs/vue/design_system/select.js @@ -0,0 +1,45 @@ +import { createApp } from 'vue/dist/vue.esm-bundler.js'; +import SelectDropdown from '../../../vue/shared/select_dropdown.vue'; +import PerfectScrollbar from 'vue3-perfect-scrollbar'; +import { mountWithTurbolinks } from '../helpers/turbolinks.js'; + +const app = createApp({ + data() { + return { + size: 'md', + } + }, + computed: { + simpleOptions() { + return [ + ['1', 'One', { icon: 'sn-icon-edit' }], + ['2', 'Two', { icon: 'sn-icon-drag' }], + ['3', 'Three', { icon: 'sn-icon-delete' }], + ['4', 'Four', { icon: 'sn-icon-visibility-show' }], + ['5', 'Five', { icon: 'sn-icon-edit' }], + ['6', 'Six', { icon: 'sn-icon-locked-task' }], + ['7', 'Seven', { icon: 'sn-icon-drag' }], + ['8', 'Eight', { icon: 'sn-icon-delete' }], + ['9', 'Nine', { icon: 'sn-icon-edit' }], + ['10', 'Ten', { icon: 'sn-icon-close' }], + ]; + }, + longOptions() { + return [ + ['1', 'Very long long long option and label to test responsivness'], + ['2', 'Two'], + ['3', 'Three'], + ['4', 'Four'], + ] + }, + renderer() { + return (option) => { + return ` ${option[1]}`; + } + } + }, +}); +app.component('SelectDropdown', SelectDropdown); +app.config.globalProperties.i18n = window.I18n; +app.use(PerfectScrollbar); +mountWithTurbolinks(app, '#selects'); diff --git a/app/javascript/vue/navigation/top_menu.vue b/app/javascript/vue/navigation/top_menu.vue index 9d134732a..d1d3a1c65 100644 --- a/app/javascript/vue/navigation/top_menu.vue +++ b/app/javascript/vue/navigation/top_menu.vue @@ -5,14 +5,11 @@
- + >
import NotificationsFlyout from './notifications/notifications_flyout.vue'; import DropdownSelector from '../shared/dropdown_selector.vue'; - import Select from "../shared/select.vue"; + import SelectDropdown from "../shared/select_dropdown.vue"; import MenuDropdown from '../shared/menu_dropdown.vue'; export default { @@ -71,8 +68,8 @@ components: { DropdownSelector, NotificationsFlyout, - Select, - MenuDropdown + MenuDropdown, + SelectDropdown }, props: { url: String, diff --git a/app/javascript/vue/shared/datatable/table.vue b/app/javascript/vue/shared/datatable/table.vue index d7dd905b0..a9024d2bf 100644 --- a/app/javascript/vue/shared/datatable/table.vue +++ b/app/javascript/vue/shared/datatable/table.vue @@ -45,11 +45,11 @@
{{ i18n.t('datatable.show') }}
- + >
@@ -59,7 +59,7 @@ diff --git a/app/views/design_elements/index.html.erb b/app/views/design_elements/index.html.erb new file mode 100644 index 000000000..0055f0bcb --- /dev/null +++ b/app/views/design_elements/index.html.erb @@ -0,0 +1,218 @@ +
+

Select

+
+
+ Sizes: + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +<%= javascript_include_tag 'vue_design_system_select' %> diff --git a/config/routes.rb b/config/routes.rb index 65900608a..d768f09bc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1010,4 +1010,12 @@ Rails.application.routes.draw do end resources :gene_sequence_assets, only: %i(new create edit update) + + if Rails.env.development? || ENV['ENABLE_DESIGN_ELEMENTS'] == 'true' + resources :design_elements, only: %i(index) do + collection do + get :test_select + end + end + end end diff --git a/config/webpack/webpack.config.js b/config/webpack/webpack.config.js index 326af2c33..512f24b55 100644 --- a/config/webpack/webpack.config.js +++ b/config/webpack/webpack.config.js @@ -48,6 +48,7 @@ const entryList = { vue_legacy_datetime_picker: './app/javascript/packs/vue/legacy/datetime_picker.js', vue_label_templates_table: './app/javascript/packs/vue/label_templates_table.js', vue_projects_list: './app/javascript/packs/vue/projects_list.js', + vue_design_system_select: './app/javascript/packs/vue/design_system/select.js' } // Engine pack loading based on https://github.com/rails/webpacker/issues/348#issuecomment-635480949