-
Notifications
You must be signed in to change notification settings - Fork 11
Updating the styles of the Button Group #134
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
55ecdd4
Adding more tokens
gjones 0c57b7e
Merge branch 'main' of https://github.com/ClickHouse/click-ui into gj…
gjones e0b836b
Minor updates
gjones 2c60c8c
Merge branch 'main' of https://github.com/ClickHouse/click-ui into gj…
gjones 5fa852c
tweaking colours
gjones 40504ce
Merge branch 'main' of https://github.com/ClickHouse/click-ui into gj…
gjones 86208a6
Getting active to work again
gjones f0e4368
Adding tests.
gjones 5a4cc08
Merge branch 'main' of https://github.com/ClickHouse/click-ui into gj…
gjones f03b6cd
Updating variables.
gjones 1e25256
Merge branch 'main' of https://github.com/ClickHouse/click-ui into gj…
gjones 60486d4
Merge branch 'main' of https://github.com/ClickHouse/click-ui into gj…
gjones 20a420f
Adding role to button group.
gjones 232e6a6
Merge branch 'main' into gj-buttonGroup
gjones e9761ec
Merge branch 'main' into gj-buttonGroup
gjones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { fireEvent } from "@testing-library/react"; | ||
import { ButtonGroup, ButtonGroupProps } from "./ButtonGroup"; | ||
import { renderCUI } from "@/utils/test-utils"; | ||
|
||
describe("ButtonGroup", () => { | ||
const renderButtonGroup = (props: ButtonGroupProps) => | ||
renderCUI(<ButtonGroup {...props} />); | ||
const labels = ["Option 1", "Option 2", "Option 3"]; | ||
|
||
it("renders buttons with labels correctly", () => { | ||
const { getByText } = renderButtonGroup({ labels: labels }); | ||
|
||
labels.forEach(label => { | ||
expect(getByText(label).textContent).toBe(label); | ||
}); | ||
}); | ||
|
||
it("calls onClick handler when a button is clicked", () => { | ||
let counter = 0; | ||
const handleClick = () => (counter = 1); | ||
|
||
const { getByText } = renderButtonGroup({ | ||
labels: labels, | ||
onClick: handleClick, | ||
}); | ||
|
||
fireEvent.click(getByText("Option 2")); | ||
|
||
expect(counter).toEqual(1); | ||
}); | ||
|
||
it("adds 'active' class to the active button", () => { | ||
const { getByText } = renderButtonGroup({ | ||
labels: labels, | ||
activeIndex: 1, | ||
}); | ||
|
||
const activeButton = getByText("Option 2"); | ||
|
||
expect(activeButton).active == true; | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// vite.config.ts | ||
import { defineConfig } from "file:///Users/garethjones/Sites/click-ui/node_modules/vite/dist/node/index.js"; | ||
import react from "file:///Users/garethjones/Sites/click-ui/node_modules/@vitejs/plugin-react/dist/index.mjs"; | ||
import path, { resolve } from "path"; | ||
import dts from "file:///Users/garethjones/Sites/click-ui/node_modules/vite-plugin-dts/dist/index.mjs"; | ||
var __vite_injected_original_dirname = "/Users/garethjones/Sites/click-ui"; | ||
var vite_config_default = defineConfig({ | ||
plugins: [ | ||
react({ | ||
babel: { | ||
plugins: [["babel-plugin-styled-components", { displayName: false }]], | ||
env: { | ||
development: { | ||
plugins: [["babel-plugin-styled-components", { displayName: true }]] | ||
} | ||
} | ||
} | ||
}), | ||
dts({ | ||
include: ["src/"], | ||
exclude: ["**/*.stories.ts", "**/*.stories.tsx", "**/*.test.ts", "**/*.test.tsx"] | ||
}) | ||
], | ||
resolve: { | ||
alias: { | ||
"@": path.resolve(__vite_injected_original_dirname, "./src") | ||
} | ||
}, | ||
build: { | ||
lib: { | ||
entry: resolve(__vite_injected_original_dirname, "src/index.ts"), | ||
name: "click-ui", | ||
formats: ["es", "umd"], | ||
fileName: (format) => `click-ui.${format}.js` | ||
}, | ||
rollupOptions: { | ||
// Add _all_ external dependencies here | ||
external: [ | ||
"react", | ||
"react-dom", | ||
"styled-components", | ||
"**/*.stories.ts", | ||
"**/*.stories.tsx", | ||
"**/*.test.ts", | ||
"**/*.test.tsx" | ||
], | ||
output: { | ||
globals: { | ||
react: "React", | ||
"styled-components": "styled", | ||
"react-dom": "ReactDOM" | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
export { | ||
vite_config_default as default | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvZ2FyZXRoam9uZXMvU2l0ZXMvY2xpY2stdWlcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9Vc2Vycy9nYXJldGhqb25lcy9TaXRlcy9jbGljay11aS92aXRlLmNvbmZpZy50c1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vVXNlcnMvZ2FyZXRoam9uZXMvU2l0ZXMvY2xpY2stdWkv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zsiLAogICJuYW1lcyI6IFtdCn0K |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.