Getting Started with the LaunchDarkly React QR Demo
This project was bootstrapped with Create React App.
Usage
Want to use GitHub Pages to publish your own copy of this? You've come to the right place!
Duplicating the repository and creating a GitHub Page
- Fork this repository
- Clone the new repository to your local machine, cloud editor, or whatever
- Run
npm install
in your local root directory of the project- NOTE: Due to an outstanding issue with Webpack and version 17+ of Node, you must use Node version 16.X or below.
- NOTE: If you receive dependency errors, you can add the
--legacy-peer-deps
flag
- In your GitHub repository, go to Settings > Pages and create a GitHub Page. Copy the URL of your GitHub Page, for use in the next section.
Modifying variables for your own usage
- In
src/components/qrCode.js
, modifyQRURL
to be your github pages URL - In
package.json
, modify the "homepage" to point to your github pages URL - In
src/index.js
, modifyCLIENTKEY
to be your own LaunchDarkly client-side SDK key
Flags used by the app
reactBackgroundColor
: A string flag withgray
,purple
,blue
, andred
as string variations.reactCustomerLogo
: A string flag with variations containing URLs of images.reactQRCode
: booleanreactParentBrand
: booleanreactChildHeaderLogo
: booleanreactChildToggle
: booleanreactShowCustomerLogo
: booleanreactShowHeart
: boolean
Creating LaunchDarkly flags
The project React QR Demo exists on the LD Production account with all the necessary flags. You can add a new environment for yourself.
If you want to create a new project with all the right flags, then you can either use the LaunchDarkly Terraform integration to set all the flags up in one go (see below), or do it manually using the list above.
Creating flags with Terraform
- Ensure that you have:
- An empty LaunchDarkly project, ready for some funky fresh flags
- An API access token with
Writer
permissions. Go to the Authorizations page to create it. - Terraform installed
- See the
terraform.tfvars.example
file in the root directory? Rename it toterraform.tfvars
. - Then edit the
terraform.tfvars
file, replacing theaccess_token
andproject_key
values. - Run:
terraform init
to initialize the configuration - Run:
terraform plan
- If that ran with no errors, then run:
terraform apply
- Go enjoy your lovely new flags!
Testing
- To test that it's working locally, run
npm start
in the root directory of your project - On your LaunchDarkly dashboard, try turning the
reactQRCode
flag on and off, and serve different colors in thereactBackgroundColor
flag
Deploying
- When you're ready,
npm run deploy
to deploy to a newgh-pages
branch of your repository - On your GitHub repository, go to Settings > Pages and ensure you're using the
gh-pages
branch in theroot
directory