Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component center img #143

Merged
merged 23 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
682bd19
refactor: add new component for image centering, change <img /> throu…
YUUU23 Jun 21, 2024
4c9d413
add: add into documentation on center_img.jsx on how to add in multip…
YUUU23 Jun 21, 2024
ab1e697
refactor: add new component for image centering, change <img /> throu…
YUUU23 Jun 21, 2024
d8610c2
add: add into documentation on center_img.jsx on how to add in multip…
YUUU23 Jun 21, 2024
805f4f2
rebase on main
YUUU23 Jun 27, 2024
5c826fb
Merge branch 'component-center-img' of https://github.com/brown-ccv/h…
YUUU23 Jun 27, 2024
2073dbe
refactor: add new component for image centering, change <img /> throu…
YUUU23 Jun 21, 2024
efb389a
add: add into documentation on center_img.jsx on how to add in multip…
YUUU23 Jun 21, 2024
e464c2d
Merge branch 'component-center-img' of https://github.com/brown-ccv/h…
YUUU23 Jun 27, 2024
9f24607
refactor: add new component for image centering, change <img /> throu…
YUUU23 Jun 21, 2024
4e7584c
add: add into documentation on center_img.jsx on how to add in multip…
YUUU23 Jun 21, 2024
87bd2aa
Merge branch 'component-center-img' of https://github.com/brown-ccv/h…
YUUU23 Jun 27, 2024
040fb9d
center_img
YUUU23 Jun 27, 2024
68f7be4
add: add into documentation on center_img.jsx on how to add in multip…
YUUU23 Jun 21, 2024
261b175
Merge branch 'component-center-img' of https://github.com/brown-ccv/h…
YUUU23 Jun 27, 2024
0fa61fe
Delete .firebaserc 2
YUUU23 Jun 27, 2024
e8a5908
Delete firebase 2.json
YUUU23 Jun 27, 2024
3639294
merge with main
YUUU23 Jul 9, 2024
aa91bf4
refactor: change semantics on component name and remove extra space
YUUU23 Jul 9, 2024
27b91da
refactor: use props delegation instead of simply props
YUUU23 Jul 9, 2024
8b899d3
refactor: use props delegation for img style
YUUU23 Jul 9, 2024
2ceddef
refactor: change to delegated, taking in image style directly
YUUU23 Jul 9, 2024
834e37b
refactor: CenteredImage component to its own component folder, correc…
YUUU23 Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/assets/center_img.jsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple semantic things here

  1. I would call this component CenteredImage as component are things ("A centered image") and not an action ("a function that centers an image") - hope that makes sense!
  2. After this could you rename the file itself to be CenteredImage.jsx? Different companies may have different naming conventions but it's generally best to give the file the same exact name as the component

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! This makes so much sense; thank you so much :) ! Just went in and refactored the semantics.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";

/**
* Component for centering an image in the docs
*
* @param {*} props :
* src: image source
* alt: image alternative text
* imgStyle: object, any image styles (props can be passed in as: `imgStyle={{ maxHeight: "600px", border: "solid" }}`)
* @returns a component for uniformally centering images in the doc
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra empty line here

Suggested change

export default function CenterImg(props) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of how you could set up the component with prop delegation

Suggested change
export default function CenterImg(props) {
export default function CenterImg({src, alt, ...delegated}) {

let imgStyleString;
if (props.imgStyle != undefined && Object.keys(props.imgStyle).length === 0) {
imgStyleString = {};
} else {
imgStyleString = props.imgStyle;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A great way of doing prop delegation is by using the spread operator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! This looks really nice and makes more sense to keep things clean. I tried to modify the current CenteredImage component to use this! Thank you!


return (
<div style={{ textAlign: "center" }}>
<img src={props.src} alt={props.alt} style={imgStyleString} />
</div>
);
}
32 changes: 10 additions & 22 deletions docs/deployments/firebase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import firebaseConsoleSettings from "../assets/firebase/firebase-console-setting
import firebaseWebCredentials from "../assets/firebase/firebase-web-credentials.png";
import firestoreCreateStudy from "../assets/firebase/firestore-create-study.png";
import firestoreExampleStudy from "../assets/firebase/firestore-example-study.png";
import CenterImg from "../assets/center_img.jsx";

Honeycomb comes with methods and configurations to deploy tasks with [Firebase](https://firebase.google.com/). These tools make it possible to reach a wider audience by hosting your task online.

Expand Down Expand Up @@ -67,17 +68,14 @@ _A `command not found` error usually indicates firebase-tools has not been insta
1. Return to your project on the [Firebase console](https://console.firebase.google.com/)
2. Navigate to your project setting

<img
<CenterImg
src={firebaseConsoleSettings}
alt="Firebase project settings"
/>

3. Scroll down and copy the auto-generated values from the Firebase console to the corresponding variables in the `.env.firebase` file in the `env` folder of your Honeycomb task repo

<img
src={firebaseWebCredentials}
alt="Firebase web credentials"
/>
<CenterImg src={firebaseWebCredentials} alt="Firebase web credentials" />
<br />
<br />

Expand Down Expand Up @@ -142,7 +140,6 @@ firebase init hosting:github
Firebase will update the files `firebase-hosting-pull-request.yml` and `firebase-hosting-merge.yml` inside the `.github/workflows/` directory. Please ensure the "run" step is `npm ci && npm run build:firebase` in both files!
:::


## Managing Data

Honeycomb ships with a CLI script for managing data in Firebase. A local service account must be created in order to use it.
Expand All @@ -152,10 +149,7 @@ Honeycomb ships with a CLI script for managing data in Firebase. A local service
Service accounts are accounts that are not attached to a human user. They authorize access to a Firebase project without someone physically logging in online. We use a service account to give the download script access to the Firestore database automatically.

1. Return to the project settings your project on the [Firebase console](https://console.firebase.google.com/)
<img
src={firebaseConsoleSettings}
alt="Firebase project settings"
/>
<CenterImg src={firebaseConsoleSettings} alt="Firebase project settings" />
2. Click on the "Service accounts" tab
3. Near the bottom, click "Generate new Private key" and "Generate Key"

Expand Down Expand Up @@ -253,20 +247,14 @@ Firestore rules define every valid path for data in your project. Attempting to
5. Click "Add Field".
6. Enter `registered_participants` as the field name, and set the type "array"
7. Add the id of each study participant to the array as type "string"

<div style={{ textAlign: "center" }}>
<img
src={firestoreCreateStudy}
alt="Create a study"
style={{ maxHeight: "600px" }}
/>
</div>
<CenterImg
src={firestoreCreateStudy}
alt="Create a study"
imgStyle={{ maxHeight: "600px" }}
/>

The study should look like this when you're finished:

<img
src={firestoreExampleStudy}
alt="Example study"
/>
<CenterImg src={firestoreExampleStudy} alt="Example study" />

**Additional studies are created as documents inside the `registered_studies` collection**
9 changes: 5 additions & 4 deletions docs/further_reading/version_control.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,26 @@ import gitBasics from "../assets/further_reading/git_basics.png";
import gitBranch from "../assets/further_reading/git_branch.png";
import createPR from "../assets/further_reading/create_pull_request.png";
import addReviewers from "../assets/further_reading/add_reviewers.png";
import CenterImg from "../assets/center_img.jsx";

## Git Overview

Git is a version control system that enables you to track changes to files. With Git, you are able to revert files back to previous versions, restore deleted files, remove added files and even track down where a particular line of code was introduced.

Nearly all operations that are performed by Git are in your local computing environment, with the exception of a few used to synchronize with the GitHub remote host. Some of the most common git operations are depicted below.

<img src={gitBasics} alt="Git basics" />
<CenterImg src={gitBasics} alt="Git basics" />

If you would like to make any changes to current repository, it is always good to start with creating a feature branch, where you can save all the changes.

<img src={gitBranch} alt="Example branches diagram" />
<CenterImg src={gitBranch} alt="Example branches diagram" />

## Create a Pull Request

Pull requests are useful before you merge your branch with the main branch. You can request a review from your colleagues and check for any conflicts with the main branch. After you pushed all the changes to your branch, you can go to the original GitHub repository and click on the pull request.

<img src={createPR} alt="Create a pull request" />
<img src={addReviewers} alt="Add reviewers to a pull request" />
<CenterImg src={createPR} alt="Create a pull request" />
<CenterImg src={addReviewers} alt="Add reviewers to a pull request" />

## Best Practices

Expand Down
56 changes: 21 additions & 35 deletions docs/quick_start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@ import template1 from "./assets/template_1.png";
import workflowPermissions from "./assets/workflow-permissions.png";
import powershellAdmin from "./assets/powershell_admin.png";

import CenterImg from "./assets/center_img.jsx";

## Creating Your Task Repository

The Honeycomb repository is a template and serves as the starting point for all tasks. Creating your repository from the template starts your project with the same directory structure and files as an existing repository.

1. Go to the [Honeycomb repository](https://github.com/brown-ccv/honeycomb)
2. Click on `Use this template` and select `Create a new repository`.

<img
src={template0}
alt="Use this template"
/>
<CenterImg src={template0} alt="Use this template" />

3. Enter the owner, name, and description of your repository and click on `Create repository from template`.

<img
src={template1}
alt="Create the repository"
/>
<CenterImg src={template1} alt="Create the repository" />

:::note
We recommend creating a public repository and leaving `Include all branches` unchecked
Expand All @@ -42,7 +38,7 @@ The Honeycomb repository is a template and serves as the starting point for all

_`Settings -> Actions -> General -> Workflow permissions`_

<img
<CenterImg
src={workflowPermissions}
alt="GitHub workflow permissions settings"
/>
Expand All @@ -56,10 +52,7 @@ With the repository now setup it can be cloned onto your computer.
1. Navigate to the repository on [GitHub](https://github.com).
2. Click the `Code` button and copy the URL

<img
src={cloneCodeButton}
alt="GitHub clone repo button"
/>
<CenterImg src={cloneCodeButton} alt="GitHub clone repo button" />

3. Open a terminal and navigate to where you want the cloned directory

Expand Down Expand Up @@ -120,10 +113,7 @@ See [Prerequisites](prerequisites) for more information about these programs.

1. Run Powershell as an admin from the start menu

<img
src={powershellAdmin}
alt="Powershell admin launcher"
/>
<CenterImg src={powershellAdmin} alt="Powershell admin launcher" />

2. Navigate to the root directory of your cloned repository
3. Paste the following command and follow the prompts to install the listed programs:
Expand Down Expand Up @@ -171,28 +161,22 @@ NVM (Node Version Manager) is a tool for installing and using multiple versions

1. Install NVM

<Tabs
groupId="os"
queryString
defaultValue="mac"
>
<TabItem
value="win"
label="Windows"
>
<Tabs groupId="os" queryString defaultValue="mac">
<TabItem value="win" label="Windows">
<em>
The previous step installs{" "}
<a href="https://github.com/coreybutler/nvm-windows">NVM for Windows</a> via the winget
package manager. Note that this is a different tool than NVM with slight differences
needed for compatibility with Windows.
<a href="https://github.com/coreybutler/nvm-windows">
NVM for Windows
</a>{" "}
via the winget package manager. Note that this is a different tool
than NVM with slight differences needed for compatibility with
Windows.
</em>
</TabItem>
<TabItem
value="mac"
label="macOS"
>
<TabItem value="mac" label="macOS">
<CodeBlock language="sh">
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
curl -o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
</CodeBlock>
</TabItem>
</Tabs>
Expand Down Expand Up @@ -386,7 +370,9 @@ The quick start guide details a [command line](version_control#git-commands) wor
// ...

export function buildTimeline(jsPsych, studyID, participantID) {
console.log(`Building timeline for participant ${participantID} on study ${studyID}`);
console.log(
`Building timeline for participant ${participantID} on study ${studyID}`
);

// highlight-delete-next-line
const timeline = buildHoneycombTimeline(jsPsych);
Expand Down