Skip to content

Commit

Permalink
Survey plugin updates: fix CSS, clean up code/comments, add survey.cs…
Browse files Browse the repository at this point in the history
…s to dist archive (#3287)

* make applyStyles private and clean up comments
* fix box shadow in input elements
* fix dropdown element width
* remove old/unused plugin-survey.css file
* add survey.css to dist archive
* add changeset
  • Loading branch information
becky-gilbert authored May 14, 2024
1 parent 11be458 commit 54e04dc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 75 deletions.
6 changes: 6 additions & 0 deletions .changeset/shy-cheetahs-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@jspsych/config": patch
"@jspsych/plugin-survey": patch
---

This fixes the incorrect width for dropdown question options (#3286), adds the survey.css file to the dist archive (#3131), and cleans up code/comments.
3 changes: 3 additions & 0 deletions packages/config/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export const createCoreDistArchive = () =>
// jspsych.css
src("packages/jspsych/css/jspsych.css").pipe(rename("/dist/jspsych.css")),

// survey.css
src("packages/survey/css/survey.css").pipe(rename("/dist/survey.css")),

// Examples
src("examples/**/*", { base: "." })
// Rewrite script source paths
Expand Down
36 changes: 0 additions & 36 deletions packages/plugin-survey/css/plugin-survey.css

This file was deleted.

1 change: 1 addition & 0 deletions packages/plugin-survey/css/survey.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ input[type="text"] {
// center the question content
.jspsych-question-content {
display: inline-block;
width: 100%;
}

// prevent question content from overflowing question border/panel
Expand Down
42 changes: 3 additions & 39 deletions packages/plugin-survey/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,45 +79,9 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
this.jsPsych = jsPsych;
}

applyStyles(survey) {
// TO DO: this method of applying custom styles is deprecated, but I'm
// saving this here for reference while we make decisions about default style

// import { StylesManager } from "survey-core";

// const colors = StylesManager.ThemeColors["default"];

// colors["$background-dim"] = "#f3f3f3";
// colors["$body-background-color"] = "white";
// colors["$body-container-background-color"] = "white";
// colors["$border-color"] = "#e7e7e7";
// colors["$disable-color"] = "#dbdbdb";
// colors["$disabled-label-color"] = "rgba(64, 64, 64, 0.5)";
// colors["$disabled-slider-color"] = "#cfcfcf";
// colors["$disabled-switch-color"] = "#9f9f9f";
// colors["$error-background-color"] = "#fd6575";
// colors["$error-color"] = "#ed5565";
// colors["$foreground-disabled"] = "#161616";
// //colors['$foreground-light'] = "orange"
// colors["$header-background-color"] = "white";
// colors["$header-color"] = "#6d7072";
// colors["$inputs-background-color"] = "white";
// colors["$main-color"] = "#919191";
// colors["$main-hover-color"] = "#6b6b6b";
// colors["$progress-buttons-color"] = "#8dd9ca";
// colors["$progress-buttons-line-color"] = "#d4d4d4";
// colors["$progress-text-color"] = "#9d9d9d";
// colors["$slider-color"] = "white";
// colors["$text-color"] = "#6d7072";
// colors["$text-input-color"] = "#6d7072";

// StylesManager.applyTheme();

// Updated method for creating custom themes
private applyStyles(survey) {
// https://surveyjs.io/form-library/documentation/manage-default-themes-and-styles#create-a-custom-theme

//colors["$border-color"] = "#e7e7e7";

survey.applyTheme({
cssVariables: {
"--sjs-general-backcolor": "rgba(255, 255, 255, 1)",
Expand All @@ -137,7 +101,6 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
"--sjs-shadow-small-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
"--sjs-shadow-medium": "0px 0px 0px 1px rgba(0, 0, 0, 0.1)",
"--sjs-shadow-large": "0px 8px 16px 0px rgba(0, 0, 0, 0.05)",
"--sjs-shadow-inner": "0px 0px 0px 1px rgba(0, 0, 0, 0.15)",
"--sjs-shadow-inner-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
"--sjs-border-light": "rgba(0, 0, 0, 0.15)",
"--sjs-border-default": "rgba(0, 0, 0, 0.15)",
Expand All @@ -162,7 +125,8 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
trial.survey_function(this.survey);
}

this.applyStyles(this.survey); // customize colors
// apply our custom theme
this.applyStyles(this.survey);

// apply our custom CSS class names
this.survey.css = jsPsychSurveyCssClassMap;
Expand Down

0 comments on commit 54e04dc

Please sign in to comment.