Skip to content

Commit

Permalink
Merge branch 'next' into ds-new-pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Anton authored May 17, 2024
2 parents 14b0ec6 + 6022f9f commit cd6b868
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/prepare-cloud-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ jobs:

- name: Enable PR automerge
id: enable-pr-automerge
if: ${{ steps.create-pr.outputs.pr_url != '' }}
run: |
gh pr merge --auto -r ${{steps.create-pr.outputs.pr_url}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete release branch step on failure
id: delete-branch
if: ${{ failure() || steps.create-pr.outputs.pr_url == '' }}
run: |
git push origin -d ${{ steps.output-variables.outputs.branch_name }}
- name: Generate commit log
id: commit-log
if: ${{ success() }}
run: |
echo 'COMMIT_LOG<<EOF' >> $GITHUB_ENV
echo $(git log --format="format:%h %s (@%aL)\n" origin/prod..origin/${{steps.output-variables.outputs.branch_name}} | sed "s/\"/'/g") >> $GITHUB_ENV
Expand All @@ -56,6 +64,7 @@ jobs:
- name: Send commit log to Slack
id: slack
uses: slackapi/[email protected]
if: ${{ success() }}
with:
payload: |
{
Expand Down
18 changes: 13 additions & 5 deletions apps/web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ module.exports = {
'no-restricted-imports': [
'error',
{
paths: ['src'],
patterns: ['@novu/dal'],
paths: [
{
name: '@novu/dal',
},
{
name: '@mantine/core',
message:
'Please avoid referencing @mantine/core directly in new or updated code. Instead, import from @novu/novui',
},
],
},
],
'@typescript-eslint/naming-convention': [
Expand All @@ -35,9 +43,9 @@ module.exports = {
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
},
],
"react-hooks/rules-of-hooks": 'error',
"react-hooks/exhaustive-deps": 'warn',
"import/extensions": 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'import/extensions': 'off',
},
env: {
'cypress/globals': true,
Expand Down
10 changes: 10 additions & 0 deletions apps/web/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
[build.environment]
DISABLE_ESLINT_PLUGIN="true"

[build]
# default build command
command = "cd apps/web && pnpm run envsetup && cd ../../ && pnpm run build:web --skip-nx-cache"

[context.deploy-preview]
command = "cd apps/web && pnpm run envsetup && cd ../../ && pnpm run build:web --skip-nx-cache"

[[redirects]]
from = "/*"
to = "/index.html"
Expand Down
2 changes: 2 additions & 0 deletions apps/web/public/env-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
window._env_ = {
SKIP_PREFLIGHT_CHECK: 'true',
REACT_APP_ENVIRONMENT: 'dev',
REACT_APP_VERSION: '$npm_package_version',
};
31 changes: 31 additions & 0 deletions libs/design-system/src/color-scheme/getColorScheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ColorScheme } from './ColorScheme';
import { getColorSchemeHtmlElement } from './getColorSchemeHtmlElement';

const DEFAULT_COLOR_SCHEME: ColorScheme = 'light';

/**
* Gets the user's preferred color scheme according to their browser settings.
* @returns ColorScheme
*/
export const getBrowserColorScheme = (): ColorScheme => {
return window?.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches ? 'dark' : DEFAULT_COLOR_SCHEME;
};

/**
* Get the current color scheme of the application based on the application html.
* @returns ColorScheme
*/
export const getCurrentColorScheme = (): ColorScheme => {
const htmlElem = getColorSchemeHtmlElement();

// fallback to browser preferences if there isn't an html element
if (!htmlElem?.classList) {
return getBrowserColorScheme();
}

return htmlElem.classList.contains('dark')
? 'dark'
: htmlElem.classList.contains('light')
? 'light'
: DEFAULT_COLOR_SCHEME;
};
14 changes: 14 additions & 0 deletions libs/design-system/src/color-scheme/getColorSchemeHtmlElement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** Get the innermost <html> element that serves as the basis for our theme */
export const getColorSchemeHtmlElement = (): HTMLHtmlElement | null => {
/**
* Avoid issues with multiple `html` elements (like in Storybook) by getting all html elements
* and taking the innermost one
*/
const htmlElements = document.querySelectorAll('html');

if (!htmlElements?.length) {
return null;
}

return htmlElements.item(htmlElements.length - 1);
};
1 change: 1 addition & 0 deletions libs/design-system/src/color-scheme/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './ColorScheme';
export * from './mapThemeStatusToColorScheme';
export * from './useColorScheme';
export * from './getColorScheme';
8 changes: 5 additions & 3 deletions libs/design-system/src/color-scheme/useColorScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useLocalThemePreference, ColorSchemePreferenceEnum } from '@novu/shared
import { useColorScheme as useMantineColorScheme } from '@mantine/hooks';
import { ColorScheme } from './ColorScheme';
import { mapThemeStatusToColorScheme } from './mapThemeStatusToColorScheme';
import { getColorSchemeHtmlElement } from './getColorSchemeHtmlElement';

/**
* Handle behavior for changing ColorSchemes or ThemeStatuses
Expand All @@ -14,9 +15,10 @@ export const useColorScheme = () => {

const setColorScheme = useCallback(
(newColorScheme: ColorScheme) => {
// avoid issues with multiple `html` elements (like in Storybook)
const htmlElements = document.querySelectorAll('html');
const htmlElem = htmlElements.item(htmlElements.length - 1);
const htmlElem = getColorSchemeHtmlElement();
if (!htmlElem) {
return;
}

htmlElem.className = newColorScheme;
_setColorScheme(newColorScheme);
Expand Down
4 changes: 4 additions & 0 deletions libs/design-system/src/config/colors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/** @deprecated: Please only use values via Panda CSS defined via tokens. If the color doesn't exist, please contact Design. */
const gradientStart = '#FF512F';
/** @deprecated: Please only use values via Panda CSS defined via tokens. If the color doesn't exist, please contact Design. */
const gradientEnd = '#DD2476';
/** @deprecated: Please only use values via Panda CSS defined via tokens. If the color doesn't exist, please contact Design. */
const error = '#E54545';

/** @deprecated: Please only use values via Panda CSS defined via tokens. If the color doesn't exist, please contact Design. */
export const colors = {
white: '#FFFFFF',
black: '#000000',
Expand Down
1 change: 1 addition & 0 deletions libs/design-system/src/config/shadows.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @deprecated: Please only use values via Panda CSS defined via tokens. If the color doesn't exist, please contact Design. */
export const shadows = {
light: '0px 5px 15px rgba(38, 68, 128, 0.05)',
medium: '0px 5px 15px rgba(122, 133, 153, 0.25)',
Expand Down

0 comments on commit cd6b868

Please sign in to comment.